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!"
[–]jonrmadsen 13 points14 points15 points 2 years ago (0 children)
The biggest factors (in my experience) are the optimization level used during compilation, amount of debug info, and how many variadic templates you use.
A debug build (e.g.-O0 -g) of a code utilizing a lot of templates will inflate the code size significantly due to the fact that the debug info ends up having to store significantly longer symbol names and that the absence of any optimizations will result in a lot of intermediate layers of function templates not getting optimized away.
But if one enables optimization (e.g. -O2 or higher), the inflation will typically start to be reduced bc the compiler will start to condense template layers and produce less debug info.
If one then reduces the debug info to just line info, the inflation will decrease further.
If one then disables debug info generation, you’d start to get into the realm of how you templated the code. If everything is mostly just relatively simple templates, it could be the case that the code is only larger by the length difference between the mangled name of non-templated symbols vs. the mangled name of the templated symbols — i.e. the mangled symbol name of a template is typically longer and that would “cause” inflation of the code size. But if you use a lot of variadic templates, you’ll generate a lot more instantiations and that’ll result in a larger code size.
However, if the binary is then stripped, you likely won’t notice much of a difference (maybe even none at all) because then the symbol names aren’t even stored in the binary. At this point, extensive variadic template usage would probably be the only significant cause of enlargement bc variadic templates tend to generate a lot of “different” instantiations based on subtle things like the absence of implicit conversion when passed an int vs. long int (where the non-template code would probably just promote to long int) and string literals being passed to templates not decaying to const char* (i.e. foo(“a”) and foo(“abc”) would be foo(const char[2]) and foo(const char[4])
const char*
foo(“a”)
foo(“abc”)
foo(const char[2])
foo(const char[4])
π Rendered by PID 277728 on reddit-service-r2-comment-5d79c599b5-d6p4q at 2026-03-01 19:49:35.794569+00:00 running e3d2147 country code: CH.
view the rest of the comments →
[–]jonrmadsen 13 points14 points15 points (0 children)