r_cpp | Unsorted

Telegram-канал r_cpp - C++ - Reddit

-

Stay up-to-date with everything C++! Content directly fetched from the subreddit just for you. Join our group for discussions : @programminginc Powered by : @r_channels

Subscribe to a channel

C++ - Reddit

Interview questions path planning in C++

Hey guys as the title says I'm going for an interview for a path planning in C++ . I'm quite comfortable with the path planning algorithms and their features. But what kind of questions should I be ready for C++ . Specially when it comes to real time performance and memory management methods , tools such valgrind available . Any idea whould be really appreciated.

https://redd.it/1dvvygu
@r_cpp

Читать полностью…

C++ - Reddit

Why is it such a misery to use visual studio compiled static libraries inside of embarcadero c++ builder

I have been wanting to move away from c++ builder and eventually tried Qt. But i was surprised to find out c++ builder gave out much smaller binaries, roughly 1mb for a very simple 'hello world' app vs something around 20mb for qt. And again c++ builder apps load and run slightly faster. However one big problem comes when consuming external static and even dynamic libraries compiled either with msvc, gcc or clang. It is literally hell to try to consume those libraries inside c++builder projects. And not to mention that 32bits projects only support libraries with 'omf' format and not the usual 'coff'. So is there a way to achieve this easily. And if not, are there some other viable c++ frameworks that have cross platform capabilities and compatibility with msvc while not giving out ginormous sized binaries. Please the output size of binaries is an important factor for me.

https://redd.it/1dvubeu
@r_cpp

Читать полностью…

C++ - Reddit

Can you change state in a const function in C++? Why? How?
https://bytesandlogs.me/can-you-change-state-in-const-function-in-cpp/

https://redd.it/1dvq5ji
@r_cpp

Читать полностью…

C++ - Reddit

How effective is the C++ Primer and Myers’ Effective Quadrilogy is for coding?

Hey, I saw on some older reddit post that the C++ primer and the effective c++ books are great intro book to coding i was if that’s still true?

https://redd.it/1dvifsm
@r_cpp

Читать полностью…

C++ - Reddit

I Am 13 And Homeschooled, Is C++ Primer (5th Edition) Good?

I Know Some C++ (Can Make Full Calculators And Stuff) And Schools Coming Up. I Really Enjoy Programming, So Will The C++ Primer 5th Edition Be A Good Choice, And If Not, Any Other Suggestions? (Preferably Books)

Also Is This The Right Book? link

https://redd.it/1dva7vc
@r_cpp

Читать полностью…

C++ - Reddit

For constrained algorithms that remove items from a container should we add _erase to the algorithms?

I just wanted to know what are the thought of the community on adding \
_erase functions to the constrained algorithms library. Adding functions ranges::remove_erase, ranges::remove_if_erase, and ranges::unique_erase, and if so what should be the return type.

https://redd.it/1dv6w1n
@r_cpp

Читать полностью…

C++ - Reddit

Is there any library in C++ similar to diskcache-python?

Something similar to this: https://github.com/grantjenks/python-diskcache

https://redd.it/1dv4x8i
@r_cpp

Читать полностью…

C++ - Reddit

The complete solution for floor(nx+y) computation

Hi, I'd like to announce a recent work by myself. I know that this whole work is very niche, but I'm just hoping that at least a few of you can find it somewhat interesting.

https://github.com/jk-jeon/idiv/blob/main/subproject/example/xi\_zeta\_region\_json.cpp

It turns out that a lot of problems of fast formatting/parsing of integers and floating-point numbers eventually boil down to the problem of quickly computing the floor of numbers of the form nx + y, where x and y are some real numbers and n is an integer ranging in a fixed interval.

The way to quickly compute floor(nx + y) is to find some other real numbers xi, zeta such that floor(nx + y) = floor(n xi + zeta) holds for all n in the prescribed range. If it is possible to take xi = m/2^(k) and zeta = s/2^(k) for some integers m, s, k, then the computation of floor(n xi + zeta) becomes just a matter of multiplying m and n, adding s to it, and then shifting it to right by k, although the original x and y can be arbitrarily complicated numbers.

For example, to compute division n / d for some integer constant d, it is easy to see that this is equivalent to computing floor(nx + y) with x = 1/d and y = 0, so we find the magic numbers m, s, k as above, which recast the computation into a multiply-add-shift. My other works on floating-point formatting/parsing (Dragonbox and floff) are all based on this kind of observations.

But until recently, I had been not able to come up with the complete solution to this problem, that is, to find the necessary and sufficient condition for xi and zeta in order to have the desired equality for all n, when the second number y is not zero. Such a situation arose when I was working on Dragonbox, as I needed to compute the floor of n * log10(2) - log10(4/3). I was able to came up with a sufficient condition back then which was good enough for the application, but I was not very happy that I couldn't come up with the full solution.

And now, I finally solved it and came up with an algorithm that computes the completely precise (modulo possible implementation bugs) full set of (xi, zeta) that satisfies floor(nx + y) = floor(n xi + zeta) for all n in a fixed range, when x and y are just any real numbers without any constraints what so ever. This is a substantial upgrade to an algorithm I announced a year ago about turning integer divisions into multiply-add-shift.

Hence, for example, we can turn not only just divisions but also any kinds of "multiply-add-divide" into a single "multiply-add-shift", as long as it is ever possible. For instance, let's say we want to compute (37 - n * 614) / 36899 for n=-9999999 ~ 9999999. Then it turns out that we can convert this into (279352803 - n * 4573973139) >> 38. (Modulo the fact that in C++ signed division does not compute the floor, rather it "rounds toward zero". And also modulo that signed bit-shift is not guaranteed to compute the floor, though it typically does. But it is possible to adapt the algorithm to C++'s signed division semantics as well, and I'm thinking of a generalization of the algorithm that accommodates this case.) Note that this kinds of tricks can be potentially useful for, for instance, doing calendar stuffs.

I got these magic numbers by running the example program above. To be precise, the program merely prints the set of (xi, zeta), and I manually found a point of the form (m/2^(k), s/2^(k)) in the printed set. But this can be easily automated and doing so is not a big deal. I just didn't finish it yet.

Another application is to the integer formatting algorithm I applied all over the places in the

Читать полностью…

C++ - Reddit

Naming Convention in C++

I'm new in the college and many of my teacher use snake case but when I googling in the internet so many time I see they written in camel case also, is there rule for this?

https://redd.it/1duxloy
@r_cpp

Читать полностью…

C++ - Reddit

Does Microsoft has plans to add Risc-V support to its C++ compiler?



https://redd.it/1dubexi
@r_cpp

Читать полностью…

C++ - Reddit

Project Ideas based on current level of C++ knowledge

Hey everybody!

I just finished highschool and am learning C++ from learncpp.com this summer. I completed upto enumerations and structs chapter and now will be starting OOP with the chapter on classes.

However, before proceeding ahead, I want to do a project with my current level of knowledge. So I ask you all to suggest me ideas that I could do.

notes:

1. This is my first time learning a language after a little html in school.
2. I dont want any impressive project for my resume, but an interesting project which will test my knowledge extensively.

Any idea will be appreciated. Thanks!

https://redd.it/1du4owl
@r_cpp

Читать полностью…

C++ - Reddit

A Type for Overload Set
https://biowpn.github.io/bioweapon/2024/07/02/a-type-for-overload-set.html

https://redd.it/1du5jrd
@r_cpp

Читать полностью…

C++ - Reddit

Report from the St. Louis 2024 ISO C++ Committee meeting
https://mpusz.github.io/mp-units/latest/blog/2024/07/02/report-from-the-st-louis-2024-iso-c-committee-meeting/

https://redd.it/1dtvqgy
@r_cpp

Читать полностью…

C++ - Reddit

What is the status of module ownership across different compilers?

According to cppreference:

> If two matching declarations are attached to different modules, and they both declare names with external linkage, the program is ill-formed; no diagnostic is required if neither is reachable from the other. In practice, there are two models:
>
> In the weak module ownership model, such declarations are considered to declare the same entity.
>
>
In the strong module ownership model, they are considered to declare different entities.

As far as I understand it, it is up to a compiler implementation to decide what to do in this situation. I've seen that there were heated discussions about which model is better years ago and my aim here absolutely isn't to repeat them, but I wanted to ask whether MSVC, GCC and Clang converged to a common model. From the limited amount of information that I was able to find online, it seems like all three major compilers are aiming for strong ownership in their (apart from MSVC mostly unfinished) implementations of modules, but this is something I've learned mainly from various informal discussions. Is it correct?

https://redd.it/1dtq46i
@r_cpp

Читать полностью…

C++ - Reddit

harePosition, int tortoisePosition)

{

return (harePosition >= TRACK_SIZE && tortoisePosition >= TRACK_SIZE);

}

https://redd.it/1dtm65e
@r_cpp

Читать полностью…

C++ - Reddit

I Have No Constructor, and I Must Initialize
https://consteval.ca/2024/07/03/initialization/

https://redd.it/1dvwiir
@r_cpp

Читать полностью…

C++ - Reddit

"Class invariants and contract checking philosophy"
https://esapulkkinen.github.io/cifl-math-library/C++/contracts.pdf

https://redd.it/1dvsgsd
@r_cpp

Читать полностью…

C++ - Reddit

Embarcadero cpp

How popular is Embarcadero Dev-C++ in cpp community? I get frequent mails with 30-40% discount. I know its originally Borland C++ and later became Embarcadero. They seem to have acquire dev c++, open source IDE? Once it was popular in programming competitions.

Is it still being used in commercial projects?Are there any advantages over visual studio c++?

https://redd.it/1dvo6pw
@r_cpp

Читать полностью…

C++ - Reddit

[OPINION] Which parts of C++ I find difficult/annoying for large-scale projects
https://youtu.be/y37NzWaqpbI?si=2F-IwvjgezhRL5Ze

https://redd.it/1dvdhtu
@r_cpp

Читать полностью…

C++ - Reddit

C++ DataFrame now has much improved documentation

We have significantly enhanced C++ DataFrame documentation.It now includes:

1. Explanation and code samples for every API
2. Better visual arrangements
3. Explanation for concepts such as multithreading, SIMD, ... and how to use them in DataFrame applications
4. Explanations and reasoning behind DataFrame design decisions, data structures, and constructs
5. Detailed explanation for benchmarks
6. References/links to other relevant sites

I am not an expert in documentation. The main purpose of this post is to get your feedback about the documentation and README content and visuals.

Thanks,

https://redd.it/1dv9q7a
@r_cpp

Читать полностью…

C++ - Reddit

C++ , TEST MY ABIITY AND SKILL level .

I have been studying c++ for few months . is there any platform where i can test my knowledge and skill level of c++ programming and concepts . a test platform as such which has topic wise test .

https://redd.it/1dv5qbo
@r_cpp

Читать полностью…

C++ - Reddit

implementations of Dragonbox/floff. Until now I had been not quite happy about my previous, somewhat ad-hoc analysis of this algorithm, but now we can analyze it fully and precisely using the new algorithm. I also wrote an example program that does this analysis.

Disclaimer: I did not polish the code and make it into a reusable library (it will take another year or more), and also did not upload anywhere the PDF file (60+ pages currently) explaining how the algorithm (and other related things in the library) works, and nobody other than me has reviewed it. Please let me know if you find any errors in the implementation.

https://redd.it/1dv2nu1
@r_cpp

Читать полностью…

C++ - Reddit

C++23: further small changes
https://www.sandordargo.com/blog/2024/07/03/cpp23-further-small-changes

https://redd.it/1duzad8
@r_cpp

Читать полностью…

C++ - Reddit

Different methods

Just out of curiosity can I solve a problem in C++ in more than one way?

https://redd.it/1dudvj0
@r_cpp

Читать полностью…

C++ - Reddit

Björn Fahller: Cache friendly data + functional + ranges = ❤️
https://youtu.be/3Rk-zSzloL4

https://redd.it/1du7hs6
@r_cpp

Читать полностью…

C++ - Reddit

Challenges after we used C++20 modules.

We have been using C++20 modules since last year in https://github.com/infiniflow/infinity. And we met some challenges that are still not well solved.


1. This project can be considered a vector database + search engine + other information retrieval method to be used by retrieval augmented generation (RAG) for LLM. Since most AI project are developed by Python, we provide a Python SDK to help Python developer to access the database easily. Now, we already provides two modes to use the Python SDK: client-server mode and embedded module. By using nanobind (https://github.com/wjakob/nanobind), we can now use Python function to access C++ function.


Here is the problem:

If we link the program with libstdc++ dynamically, the Python SDK works fine with other python modules. But only recent libstdc++ versions support C++20 library, we have to request our users to upgrade their libstdc++.

If we link the program with libstdc++ statically, it seems the Python SDK will conflict with other Python modules such as PyTorch.

If anyone could give us some advice, I would greatly appreciate it.

2. By using C++20 modules, we did reduce the whole compilation time. We also meet the situation that only one module interface file needs to be updated, but all files that import the module interface file have to be re-compiled.

3. Now, we use clang to compile the project, which makes it hard for us to switch to gcc.




https://redd.it/1du5adg
@r_cpp

Читать полностью…

C++ - Reddit

Trip report: Summer ISO C++ standards meeting (St Louis, MO, USA)
https://herbsutter.com/2024/07/02/trip-report-summer-iso-c-standards-meeting-st-louis-mo-usa/

https://redd.it/1du3i63
@r_cpp

Читать полностью…

C++ - Reddit

Implementing General Relativity in C++: Wormholes, spinning black holes, accretion disks, and redshift
https://20k.github.io/c++/2024/07/02/wormholes.html

https://redd.it/1dtu0p9
@r_cpp

Читать полностью…

C++ - Reddit

Latest News From Upcoming C++ Conferences (07/02/2024)

This Reddit post will now be a roundup of any **new** news from upcoming conferences with then the full list now being available at [https://programmingarchive.com/upcoming-conference-news/](https://programmingarchive.com/upcoming-conference-news/)

**New News**

* **ACCU** - Have started releasing their videos! If you want to stay up to date as new videos are released, then subscribe to their YouTube Channel! [ACCUConf" rel="nofollow">https://www.youtube.com/@ACCUConf](ACCUConf" rel="nofollow">https://www.youtube.com/@ACCUConf)
* **C++Now** - Have added a third batch of 2024 videos to their early access portal. More information about early access including what videos have been added to the early access portal can be found here [https://cppnow.org/announcements/2024/06/early-access-now-open-for-cnow-2024-youtube-videos/](https://cppnow.org/announcements/2024/06/early-access-now-open-for-cnow-2024-youtube-videos/) and anyone who attended C++Now 2024 or who has purchased an early access pass should already have information about how to access the portal.
* **C++OnSea** - The main Conference starts tomorrow! You can still buy tickets here [https://cpponsea.uk/tickets/](https://cpponsea.uk/tickets/).
* **CppNorth** - Have extended their special offer which gives a $800 discount. More information can be found here [https://cppnorth.ca/news-2024-hotel-discount-extension.html](https://cppnorth.ca/news-2024-hotel-discount-extension.html) and is now available while stock lasts
* **CppIndiaCon**
* The call for speakers has now closed.
* Early Bird Tickets have now finished. Regular tickets can be purchased here [https://konfhub.com/cppindiacon2024](https://konfhub.com/cppindiacon2024)
* **CppCon**
* Early Bird Tickets are no longer available with tickets now being sold at the standard price.
* Applications for the "Attendance Support Ticket program" is now closed
* **C++ Under the Sea** - have announced details and released tickets for workshops that will take place on the 10th October. More information can be found here [https://cppunderthesea.nl/workshops/](https://cppunderthesea.nl/workshops/)
* **Audio Developer Conference (ADC)**
* Registration is now open for ADC 2024 and early bird tickets can be purchased at [https://audio.dev/tickets](https://audio.dev/tickets)
* The call for speakers is now closed
* **Meeting C++** - The call for speakers has been extended with the deadline now being midnight on the 3rd July. Find out more at [https://meetingcpp.com/meetingcpp/news/items/Contribute-your-talk-to-Meeting-Cpp-2024-.html](https://meetingcpp.com/meetingcpp/news/items/Contribute-your-talk-to-Meeting-Cpp-2024-.html)

https://redd.it/1dtq4xe
@r_cpp

Читать полностью…

C++ - Reddit

position after getting the speed



display_track(harePosition, tortoisePosition, 'H', 'T', obstacles, numObstacles); // display the track inside the loop



cout << endl << endl;

cout << "The speed of Tortoise was: " << tortoiseSpeed << endl; // tells the speed of Tortoise in this round

cout << "The speed of Hare was: " << hareSpeed << endl; // tells the speed of Hare in this round

cout << endl;



int winner = checkWinner(harePosition, tortoisePosition);



if (checkTie(harePosition, tortoisePosition)) // checks if both hare and tortoise passed the line to make tie

{

cout << "It's a tie!" << endl;

break;

}

else if (winner == 2) // if no tie then the code checks if tortoise is the winner

{

cout << "Congratulations to: " << "Username: " << name2 << " " << "Email: " << email2 << " Tortoise wins!" << endl;

break; // break out of the loop if tortoise wins

}

else if (winner == 1) // if no tie then the code checks if hare is the winner

{

cout << "Congratulations to: " << "Username: " << name1 << " " << "Email: " << email1 << " Hare wins!" << endl;

break; // break out of the loop if hare wins

}

}



return 0;

}



//Race Track

void display_track(int position1, int position2, char character1, char character2, const int obstacles[\], int numObstacles) // character1 will be hare - character2 will be tortoise

{

const int WIDTH = 31; // width and height of the track

const int HEIGHT = 11;



char track[HEIGHT\][WIDTH\]; // array to make the track



// initialise all to spaces

for (int i = 0; i < HEIGHT; i++)

for (int j = 0; j < WIDTH; j++)

track[i\][j\] = ' ';



// top track

for (int i = 0; i <= 2; i = i + 2)

{

for (int j = 0; j < WIDTH - 1; j = j + 3)

{

track[i\][j\] = '+';

track[i\][j + 1\] = '-';

track[i\][j + 2\] = '-';

}

track[i\][WIDTH - 1\] = '+';

}



for (int j = 0; j < WIDTH; j = j + 3)

track[1\][j\] = '|';



// left and right tracks - vertical lines

for (int i = 3; i < HEIGHT - 3; i = i + 2)

{

track[i\][0\] = '|';

track[i\][3\] = '|';

track[i\][WIDTH - 4\] = '|';

track[i\][WIDTH - 1\] = '|';

}



// left track - horizontal lines

for (int i = 4; i < HEIGHT - 3; i = i + 2)

{

track[i\][0\] = '+';

track[i\][1\] = '-';

track[i\][2\] = '-';

track[i\][3\] = '+';

}



// right track - horizontal lines

for (int i = 4; i < HEIGHT - 3; i = i + 2)

{

track[i\][WIDTH - 4\] = '+';

track[i\][WIDTH - 3\] = '-';

track[i\][WIDTH - 2\] = '-';

track[i\][WIDTH - 1\] = '+';

}



// bottom track

for (int i = HEIGHT - 3; i < HEIGHT; i = i + 2)

{

for (int j = 0; j < WIDTH - 1; j = j + 3)

{

track[i\][j\] = '+';

track[i\][j + 1\] = '-';

track[i\][j + 2\] = '-';

}

track[i\][WIDTH - 1\] = '+';

}



for (int j = 0; j < WIDTH; j = j + 3)

track[HEIGHT - 2\][j\] = '|';



// placing obstacles

for (int i = 0; i < numObstacles; ++i) {

int obstaclePos = obstacles[i\];

int row = HEIGHT - 2 - (obstaclePos / (WIDTH / 3) * 2);

int col = (obstaclePos % (WIDTH / 3)) * 3 + 1;

track[row\][col\] = 'X';

}



// assigning the symbol position of racer 1 (hare)

int row1 = HEIGHT - 2 - (position1 / (WIDTH / 3) * 2);

int col1 = (position1 % (WIDTH / 3)) * 3 + 1;



// assigning the symbol position of racer 2 (tortoise)

int row2 = HEIGHT - 2 - (position2 / (WIDTH / 3) * 2);

int col2 = (position2 % (WIDTH / 3)) * 3 + 1;



// track location of racers

track[row1\][col1\] = character1;

track[row2\][col2\] = character2;



// display the track

for (int i = 0; i < HEIGHT; i++)

{

for (int j = 0; j < WIDTH; j++)

cout << track[i\][j\];

cout << endl;

}

}



// generates the speed of characters

int characterSpeed(int minSpeed, int maxSpeed)

{

return rand() % (maxSpeed - minSpeed + 1) + minSpeed;

}



// checks if hare or tortoise passed the finish line

int checkWinner(int harePosition, int tortoisePosition)

{

if (harePosition >= TRACK_SIZE)

return 1;

else if (tortoisePosition >= TRACK_SIZE)

return 2;

else

return 0;

}



// checks if both hare and tortoise passed the finish line to make a tie

bool checkTie(int

Читать полностью…
Subscribe to a channel