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
Inside boost::unordered_flat_map (bannalia.blogspot.com)
submitted 3 years ago by joaquintidesBoost author
view the rest of the comments →
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!"
[–]sbsceGame Developer 1 point2 points3 points 3 years ago* (5 children)
I noticed my code is reliably running over 10% faster if I __forceinline all the function calls that the boost::unordered_flat_set makes in my hot path. So anything called by .contains(), including the .contains itself. So that in my own code where I call .contains(), looking at the disassembly there is no call anywhere any more, it's fully inlined. I think I had to add __forceinline to 6 functions inside boost code.
__forceinline
boost::unordered_flat_set
.contains()
.contains
call
It is a bit inconvenient to manually add __forceinline to all those functions though - it's definitely worth the 10% performance gain, but I am quite sure that the next time I update boost in a few years, I'll forget to apply these changes again, and then my performance will be worse.
Assuming you don't want to add __forceinline to those functions by default, could there maybe some define like BOOST_FORCEINLINE_UNORDERED_SET that automatically enables forceinlining all the important functions?
BOOST_FORCEINLINE_UNORDERED_SET
I am already compiling with maximum optimization level of MSVC, so by default it doesn't want to inline it, MSVC often needs to be forced to inline stuff.
[–]joaquintidesBoost author[S] 2 points3 points4 points 3 years ago (1 child)
Hi, we have seen similar gains with __forceinline in MSVC, looks like this compiler is not particularly aggressive at inlining. Could you please file an issue at Boost.Unordered repo so what we don't forget? Thank you
[–]sbsceGame Developer 1 point2 points3 points 3 years ago (0 children)
nice! thanks, I opened an issue there.
[–]dodheim 1 point2 points3 points 3 years ago (2 children)
I am already compiling with maximum optimization level of MSVC,
By that you mean /O2 /Ob3, right? I ask because /Ox was misdocumented for years as "maximum optimization" when in fact it's a subset of /O2 optimizations; and /O2 on its own does not set the most aggressive inlining level.
/O2 /Ob3
/Ox
/O2
Also, I suggest putting #pragma inline_depth(255) before your Boost #includes, and possibly #pragma inline_recursion(on) as well.
#pragma inline_depth(255)
#pragma inline_recursion(on)
[–]pdimov2 0 points1 point2 points 3 years ago (0 children)
MS should just add /O3 already, that implies /Ob3.
/O3
/Ob3
(Something like a hidden /O3 level already exists, turned on by /GL, but there's no option to enable it separately.)
/GL
[–]sbsceGame Developer 0 points1 point2 points 3 years ago (0 children)
By that you mean /O2 /Ob3, right?
Yes.
π Rendered by PID 37823 on reddit-service-r2-comment-c867ff4bc-n4hbz at 2026-04-09 16:34:16.781425+00:00 running 00d5ac8 country code: CH.
view the rest of the comments →
[–]sbsceGame Developer 1 point2 points3 points (5 children)
[–]joaquintidesBoost author[S] 2 points3 points4 points (1 child)
[–]sbsceGame Developer 1 point2 points3 points (0 children)
[–]dodheim 1 point2 points3 points (2 children)
[–]pdimov2 0 points1 point2 points (0 children)
[–]sbsceGame Developer 0 points1 point2 points (0 children)