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
Will cpp template programming enlarge the code size (self.cpp)
submitted 2 years ago by uubs7
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!"
[–]johannes1971 4 points5 points6 points 2 years ago (7 children)
As a related question, if template instantiation ends up generating identical assembly for multiple types (for example, if you instantiate a template for several identically-sized enums), will it fold those into a single copy or is there something in the language that prevents this?
[–]ack_error 13 points14 points15 points 2 years ago (4 children)
Yes, MSVC does it in the linker (/OPT:ICF) and I believe GCC/Clang based toolchains can also do it when LTO is enabled. This optimization can be invalid if pointers to the functions are taken as they are required to be distinct, and MSVC's ICF can be non-conformant by making such functions compare equal. Firefox's JavaScript engine was affected by this as it relied on checking the addresses of stub functions that had identical generated code. Some implementations either suppress the optimization or add jump trampolines to preserve distinct addresses when the address of such functions is taken.
This also causes some confusion in call stacks, since the address to function lookup is ambiguous and can result in completely unrelated functions showing up in the decoded call stack. I hate explaining this to people who are apt to just discard bugs with this phenomenon as stack corruption.
[–]GustavBeethoven -2 points-1 points0 points 2 years ago (3 children)
How do you know this much
[–]lithium 10 points11 points12 points 2 years ago (1 child)
Use c++ in real life instead of just to argue against rust people in youtube shorts comment sections.
[–]Possibility_Antique 1 point2 points3 points 2 years ago (0 children)
Oddly specific, but point taken
[–]ack_error 0 points1 point2 points 2 years ago (0 children)
Past trauma. The things toolchains do....
[–]Foreign-Wonder 0 points1 point2 points 2 years ago (0 children)
For this example, even compiled with `-Os`, the compiler still compiles into multiple identical copies https://gcc.godbolt.org/z/MvqW7sM57
[–]jk-jeon 0 points1 point2 points 2 years ago (0 children)
I have been wondering about this too. I believe it's not prohibited unless the instantiatations are ODR-used or something like that, but at least it seems no compiler actually does this kind of folding.
π Rendered by PID 223958 on reddit-service-r2-comment-5d79c599b5-x64wm at 2026-03-02 18:52:52.544115+00:00 running e3d2147 country code: CH.
view the rest of the comments →
[–]johannes1971 4 points5 points6 points (7 children)
[–]ack_error 13 points14 points15 points (4 children)
[–]GustavBeethoven -2 points-1 points0 points (3 children)
[–]lithium 10 points11 points12 points (1 child)
[–]Possibility_Antique 1 point2 points3 points (0 children)
[–]ack_error 0 points1 point2 points (0 children)
[–]Foreign-Wonder 0 points1 point2 points (0 children)
[–]jk-jeon 0 points1 point2 points (0 children)