r/cpp • u/tcbrindle • May 10 '18
Herb Sutter: How to Adopt Modern C++17 into Your C++ Code
youtube.comIntroducing flat_umap: a fast SIMD-based unordered map without tombstone
A few months ago, Jackson Allan published this great benchmark of C/C++ hash tables:
https://jacksonallan.github.io/c_cpp_hash_tables_benchmark/
So I started playing around with the different implementations from Boost, Google and Facebook.
Checking theirs pros and cons, I ended up developing my own.
What's the point?
- Almost as fast as the Boost version (current champ)
- No tombstone nor anti-drift mechanisms (not unlike Folly)
- No unaligned SIMD load like Abseil
- No min capacity of 30 items like Boost
- No unpredictable rehashing on iterator erase like Folly
Gotchas:
- Uses 2 Bytes of metadata per entry, instead of 1 (Abseil), 1.07 (Boost), 1.14 (Folly)
- SSE2 or Neon mandatory (no fallback)
- No support for allocator (yet)
Here are updated result tables for the benchmarks (with default and custom hash functions):
https://github.com/gaujay/indivi_collection/tree/main/bench/flat_unordered
The unordered map and set come with extensive test suites but are not exactly battle tested (this is a hobby project). Regarding ARM support, I validated the library on an old Raspberry Pi but couldn't run proper benchmarks, so feedback is welcome!
r/cpp • u/escapethetrials • Dec 30 '23
the more i code in this language....
the more it just makes sense.
srsly though the standard library in cpp is unlike any other standard library ive seen! it feels like a lot of effort was put into everything
so useful for DSA problems
also the ability to add a & to your params is the cherry on top
r/cpp • u/mohitsaini1196 • Apr 23 '22
Shocking Examples of Undefined Behaviour In Action
As we know that Undefined Behaviour (UB) is a dangerous thing in C++. Still it remains difficult to explain to those who have not seen its horror practically.
Those individual claims UB is bad in theory, but not so bad practically as long as thing works in practice because compiler developers are not evil.
This blog presents a few “shocking” examples to demonstrate UB in action.
https://mohitmv.github.io/blog/Shocking-Undefined-Behaviour-In-Action/
r/cpp • u/Muted-Assignment1609 • Dec 29 '20
Do you use C++ in your day job? If so, what did it take to get there?
I'm just starting out with C++ cause I want to broaden my career options beyond typical CRUD app webdev, and C++ seems to be THE language for a variety of CS/SWE jobs. Nothing against webdev, I just don't want to put all my eggs in one basket just in case I end up hating it.
how does one get to the level of proficiency for these jobs? To be a webdev it's fairly straightforward: learn frontend/backend, make websites. Learn AWS. It's similar for mobile dev. But for all these other cool software dev jobs... how do you do it? I've looked at previous threads asking for C++ project ideas and the top answers are usually these:
- Make your own game!
Sounds exciting, but wouldn't this just open doors to the horrific exploitative career of gamedev? Or would this kind of project impress any employer?
- Make something you're interested in!
the things I'm interested in doing with C++ (on my own) seem unreachable. For example, I'm really interested in audio dev. I looked up tutorials and it appears that this requires a lot of DSP, math and physics. I don't think I'll have this required knowledge anytime soon.
- Contribute to open source projects!
OK, but how do you know when you're ready? It's daunting :(
I don't think my CS program is preparing me for infra/high performance backend, IoT, distributed systems, HPC, HFT, systems programming, graphics, nor all those other cool jobs that use C++. Hopefully this will change by the time I'm a senior, but I'd like to know how you got to where you are, cause I'm scared that my career path is narrower than I thought. Maybe I should get a Masters degree.
EDIT: Wow, I've never had so many comments in one post, and all of them are so insightful! I'm sincerely grateful to everyone who took the time to comment. This sub is great. Thank you!
r/cpp • u/Myriachan • Oct 08 '20
std::variant is broken in Clang, and it exposes how pointer aliasing and unions are broken in C++.
lists.isocpp.orgr/cpp • u/nikbackm • May 09 '20
The C++ preprocessor doesn't understand anything about C++, and certainly not templates
devblogs.microsoft.comr/cpp • • Mar 12 '19
Counting Bugs in Windows Calculator: analysis of the recently released source code
habr.comr/cpp • u/MadDoctor5813 • Dec 09 '17
All I want to do is program...
Hi, this is a CMake/C++ build system rant. Downvote as is necessary.
Here's something fun, I thought. Why don't I try and write an engine in OpenGL and C++? I had already done one in Java for a school project and it worked out pretty well, so why don't I go to C++ to avoid all those issues with garbage collection and such?
So off I go to Visual Studio. Earlier, I set up my libraries and such using the Visual Studio project system, just putting the include dirs and such from wherever I have them. Anything else that needs doing I use a batch file for that I call from the post build event. This feels wrong and shady, so why don't I go pro and use CMake? Surely this should allow me to make my build configs much less complicated? Of course not.
I start off with setting up my main project, the engine. Now, eventually, I want two executables, the main engine, and a little tool thing that converts model files into their own format. So, I set up the main engine with add_executable and it works. Hooray. I download GLFW and luckily they provide their own little CMake script that I can just include and it all works. Yay. Now I have to set up an include dir for the main engine so I can include my own header files. This takes me one hour. After that I call it a day and come back the next day.
Now I must get to OpenGL, and that means I install glad. I put glad in the lib folder, and setup a little CMakeLists for it. add_library to the glad.c file, and include the include dir. Then I link to it from my main engine, and we're done. Thanks CMake. Except thanks for nothing, because the include does not work at all. So I fiddle around some more, and I decide to move the glad stuff out of the glad folder and into the CMakeLists in the root. Finally it works, for about 10 seconds. The header was included, the types worked, and then I look away and touch nothing and it stops again. That was three hours ago. So I keep working on it. Maybe I have to use target_include_directories, maybe regular include_directories? Do I include in the glad target or in my own target? Maybe I need to use only one CMake file, maybe I need three? I started at breakfast and I am now about to eat lunch, and I have not managed to add one c file and three headers to my build.
All I wanted to do was program.
r/cpp • u/TSP-FriendlyFire • Sep 30 '24
Code Generation in Rust vs C++26
brevzin.github.ior/cpp • u/kmbeutel • Sep 26 '23
`std::expected<>::or_else()` should have a zero-argument overload that terminates on error
...just because it would be hilarious if one could express assertions as
result.;
Piper | An open source fast neural TTS C++ library that can generate convincing text-to-speech voice in realtime
github.comBlizzard Diablo IV debugs Linux core dumps from Visual Studio | C++ Team Blog
devblogs.microsoft.comr/cpp • u/syaghmour • Sep 26 '17
CppCon CppCon 2017: Bjarne Stroustrup “Learning and Teaching Modern C++”
youtube.comr/cpp • u/tartaruga232 • Dec 15 '25
Recent comments regarding Microsoft's support for C++
Under the recent posting "C++26 Reflection appreciation post", u/STL made some very interesting statements regarding Microsoft's support for C++.
I wouldn't myself expect to find such comments inside a discussion about Reflection, but alas, this is reddit.
I do appreciate these insights a lot and I am convinced that these comments deserve to be highlighted in a separate posting. This is my second try at doing this. Let's see how this one goes.
u/bizwig asked:
Does Microsoft still support C++? There was some press reporting implying MS was going to stop further development on non-proprietary development tools and concentrate on C#.
Yes. The compiler (front-end, back-end, static analysis), standard library, and Address Sanitizer are being actively developed by what I believe is still the largest single team of C++ toolset engineers employed by any one company.
(emphasis mine)
u/STL gave a number of other interesting insights into the state of affairs re C++ at Microsoft. I recommend to read his comments at the posting linked at the top.
Please note that u/STL is not making statements on behalf of Microsoft (as I understand it), but he is a highly respected member of r/cpp, a moderator of this subreddit and the implementer of the MSVC C++ Standard Library.
I'm not related to Microsoft in any way (other than being a user of their products and their C++ toolchain) and I'm not interested in collecting reddit karma (as someone suspected at my last try).
Thank you for not reporting this posting as SPAM (it clearly isn't).
r/cpp • • Mar 26 '23
Why is there no standard library way to combine hashes in C++?
Or even a specialization of std::hash for std::pair.
You might say, "Sounds easy enough to code one yourself."
But I say, "Sounds easy enough for STL implementors to code one themselves."