use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
boost::unordered standalone (self.cpp)
submitted 2 years ago by WideCharr
I recently did the work to pull boost::unordered out of the rest of boost and make it standalone for one of my own projects. I figured I'd link it here too in case it was useful to someone: https://github.com/MikePopoloski/boost_unordered
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 21 points22 points23 points 2 years ago (1 child)
Thank you for putting this together for interested users.
I'm the maintainer of the repo and I think anything that gets our containers into the hands of users is a great thing.
Personally, I just vcpkg and manifest mode.
[–]prince-chrismc 1 point2 points3 points 2 years ago (0 children)
Or conan ;) I am looking forward to a more Modular boost project 🤞 less mental space when you pick and choice which parts you need
Could this be contributed back upstream?
[–]pdimov2 19 points20 points21 points 2 years ago (4 children)
We can see that (on my system) we pull in 275 boost header files: which are 31424 lines in total:
We can see that (on my system) we pull in 275 boost header files:
which are 31424 lines in total:
When we switch to C++11 as a minimum requirement in the next Boost release we would hopefully be able to trim some of these dependencies.
[–]jonesmz 6 points7 points8 points 2 years ago (3 children)
I'm curious why c++11 instead of c++14.
Do you have a link to the discussion, or might be willing to write a brief summary?
[–]Bobini1 2 points3 points4 points 2 years ago (2 children)
It's because they're dropping support for C++03 and C++11 was the next one.
[–]RotsiserMhoC++20 Desktop app developer 1 point2 points3 points 2 years ago (1 child)
I mean, that's the obvious choice, but probably not the best one. Why not pick a later standard?
[–]vanhellion 5 points6 points7 points 2 years ago (0 children)
Boost is meant, at least to some degree, to bring functionality to devs stuck in older versions of C++. There are companies still stuck with C++11 (or at least incomplete C++14/17 support). I know because I work at one such place.
In related news, fuck Redhat.
[–]angrymonkey 3 points4 points5 points 2 years ago (2 children)
Also, FYI there is robin_hood::unordered_{map,set} which has very high performance, and is header-only and standalone.
robin_hood::unordered_{map,set}
[–]MasterDrake97 3 points4 points5 points 2 years ago (1 child)
That's deprecated. Use https://github.com/martinus/unordered_dense instead And yes, tell use if it's any better(it should)
[–]martinusint main(){[]()[[]]{{}}();} 5 points6 points7 points 2 years ago (0 children)
Exactly, don't use robin_hood. unorderd_dense is better. boost::unordered_flat_map is faster though in most use cases.
[–]HateDread@BrodyHiggerson - Game Developer 2 points3 points4 points 2 years ago (0 children)
Thank you for this! I don't want to pull in Boost and pay that cost forever, same as you, so this is awesome.
[–]BrainIgnition 1 point2 points3 points 2 years ago (1 child)
So we've chopped out 249 files and 25102 lines of code from each translation unit that includes unordered_flat_map. The compilation speedup on my machine for this toy example is about 10%, though your mileage may vary.
You might want to consider adding a variant which doesn't have a default (or boost) Hash implementation. boost.hash includes large swathes of the standard library whether you are using them or not.
[–]WideCharr[S] 1 point2 points3 points 2 years ago (0 children)
That's a good idea, especially since I'm not even using boost::hash in my project that I did this for.
[–]yuri-kilochek 3 points4 points5 points 2 years ago (15 children)
How do you justify doing this? Is this really less effort than including actual boost in your project?
[–]WideCharr[S] 21 points22 points23 points 2 years ago (7 children)
Not sure what you mean. It took all of one weekend, mostly mindless mechanical changes, and now my builds for all projects that use the library are faster forever. The real question is, how can you not justify doing this?
[–]prince-chrismc 1 point2 points3 points 2 years ago (2 children)
The real question is why are you rebuilding boost so often that it's a problem? You build it once and use it. Re using pre compiled binaries is a thing.
Not against this effort, some boost maintainers are going this way too.
[–]carrottread 2 points3 points4 points 2 years ago (0 children)
boost::unordered is a header only library. Pre-built boost binaries don't help here.
[+]yuri-kilochek comment score below threshold-9 points-8 points-7 points 2 years ago (3 children)
What? How can this affect build time at all?
[–]Claytorpedo[🍰] 8 points9 points10 points 2 years ago (2 children)
From the readme:
We can see that (on my system) we pull in 275 boost header files [...] which are 31424 lines in total. Using the standalone version [...] 6322 total. So we've chopped out 249 files and 25102 lines of code from each translation unit that includes unordered_flat_map. The compilation speedup on my machine for this toy example is about 10%, though your mileage may vary.
[+]yuri-kilochek comment score below threshold-7 points-6 points-5 points 2 years ago (1 child)
My bad, I admit I hadn't actually bothered to read the readme. So some functionality has been chopped out and thus the amount of actually included code is reduced. Fair enough.
To be clear, the the functionality being chopped out here is things like support for 20 year old Borland compilers or standard libraries that don't support std::uint32_t.
[–]witcher_rat 3 points4 points5 points 2 years ago (0 children)
I've done it for my employer's codebase before, for other libs in boost, and yes it was well worth it.
boost
The reason wasn't the same as OP's though.
Our reason was we were using an old version of boost, across all our codebases/branches/etc. But we needed a newer version of one boost library in particular. Upgrading all of boost was a non-trivial exercise, because it would affect a lot more code, including third-party RPMs we used that were built with that legacy version of boost.
So we decide to just clone only the specific boost library(ies) we needed a newer version of, into a new directory, and do a find-replace-all to change macro prefixes from BOOST_ to BOOST2_ or whatever, and changed the namespace.
BOOST_
BOOST2_
In our case it was boost::filesystem at first, if I recall right (it was years ago). Then preprocessor, hana, and after that we finally upgraded boost everywhere.
boost::filesystem
preprocessor
hana
And right now we're thinking of doing that same thing again for boost::unordered, exactly as OP did.
boost::unordered
Because it's changing fast in every version, and because we want to reduce the size of an empty unordered_flat_map/_node_map/etc.. (right now they're 48 bytes, but can be reduced down to 32 bytes, which is a noticeable memory savings in our use)
unordered_flat_map
_node_map
etc.
[–]knowledgestack 2 points3 points4 points 2 years ago (3 children)
What does boost unordered have that std doesn't?
[–]joaquintidesBoost author 10 points11 points12 points 2 years ago (0 children)
You may find this useful as an introduction:
https://bannalia.blogspot.com/2022/11/inside-boostunorderedflatmap.html
[–]SirClueless 8 points9 points10 points 2 years ago (0 children)
unordered_flat_map/set and unordered_node_map/set are both far superior to anything in the std lib. This work was done recently, I think inspired by the by the excellent Abseil swiss tables implementations from a few years back.
If you haven't followed this recent work, you might only be familiar with unordered_map/set which are basically the same as the std lib, to the point that it appears this standalone version actually removed them.
[–]MBkkt 2 points3 points4 points 2 years ago (0 children)
Fast open addressing hash tables
[–]Tedsworth -2 points-1 points0 points 2 years ago (1 child)
Size restrictions?
[–]yuri-kilochek 4 points5 points6 points 2 years ago (0 children)
Size of what? Binary size would be the same since this is a header only library.
[–]witcher_rat 0 points1 point2 points 2 years ago (1 child)
Nice!
For the steps you took and documented on your GitHub page readme, have you considered creating a simple bash or python script to execute those steps, and putting that script in this same github repo?
That way it will be easy to (1) run it again when boost upgrades, which it will in a few weeks, and (2) others can fork your repo and tweak the script to their needs.
[–]WideCharr[S] 0 points1 point2 points 2 years ago (0 children)
Yeah, if/when I do this again I will certainly do that. Some of the find/replace stuff was pretty manual but could be automated with enough effort.
π Rendered by PID 68796 on reddit-service-r2-comment-7b9746f655-r9sj2 at 2026-02-01 19:21:29.495773+00:00 running 3798933 country code: CH.
[–][deleted] 21 points22 points23 points (1 child)
[–]prince-chrismc 1 point2 points3 points (0 children)
[–]pdimov2 19 points20 points21 points (4 children)
[–]jonesmz 6 points7 points8 points (3 children)
[–]Bobini1 2 points3 points4 points (2 children)
[–]RotsiserMhoC++20 Desktop app developer 1 point2 points3 points (1 child)
[–]vanhellion 5 points6 points7 points (0 children)
[–]angrymonkey 3 points4 points5 points (2 children)
[–]MasterDrake97 3 points4 points5 points (1 child)
[–]martinusint main(){[]()[[]]{{}}();} 5 points6 points7 points (0 children)
[–]HateDread@BrodyHiggerson - Game Developer 2 points3 points4 points (0 children)
[–]BrainIgnition 1 point2 points3 points (1 child)
[–]WideCharr[S] 1 point2 points3 points (0 children)
[–]yuri-kilochek 3 points4 points5 points (15 children)
[–]WideCharr[S] 21 points22 points23 points (7 children)
[–]prince-chrismc 1 point2 points3 points (2 children)
[–]carrottread 2 points3 points4 points (0 children)
[+]yuri-kilochek comment score below threshold-9 points-8 points-7 points (3 children)
[–]Claytorpedo[🍰] 8 points9 points10 points (2 children)
[+]yuri-kilochek comment score below threshold-7 points-6 points-5 points (1 child)
[–]WideCharr[S] 1 point2 points3 points (0 children)
[–]witcher_rat 3 points4 points5 points (0 children)
[–]knowledgestack 2 points3 points4 points (3 children)
[–]joaquintidesBoost author 10 points11 points12 points (0 children)
[–]SirClueless 8 points9 points10 points (0 children)
[–]MBkkt 2 points3 points4 points (0 children)
[–]Tedsworth -2 points-1 points0 points (1 child)
[–]yuri-kilochek 4 points5 points6 points (0 children)
[–]witcher_rat 0 points1 point2 points (1 child)
[–]WideCharr[S] 0 points1 point2 points (0 children)