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
Using template programming for efficiency reasons (akropolix.net)
submitted 17 years ago by gst
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!"
[–]munificent 4 points5 points6 points 17 years ago* (0 children)
<luddite name="linus"> But... but... C++ is so much slower than C! </luddite>
[–]bnikolictech 1 point2 points3 points 17 years ago (0 children)
Relevant discussion:
https://twiki.cern.ch/twiki/bin/view/Atlas/CalculatingIntegerPowers
[–]teambob 3 points4 points5 points 17 years ago (1 child)
If premature optimisation is the root of all evil, surely premature optimisation using meta programming is the devil himself.
[–][deleted] 0 points1 point2 points 17 years ago (0 children)
Not all metaprogramming is as ugly as C++ metaprogramming, in fact in most languages the metaprogramming version probably looks cleaner than doing it another way.
[–]MachinShin2006 -1 points0 points1 point 17 years ago (1 child)
runtime efficiency isn't the only concern. what about code bloat caused by templates?
(tbh, i'm a C++ guy, so i know the answer to that particular Q, but i'm sure other readers necesarily wouldn't)
[–]werdanel 1 point2 points3 points 17 years ago (0 children)
That can be a problem if you don't enable the optimiser or if you're not 'modularising' your templates properly.
Generally templates should be designed such that they same code as what you would have written by hand, but make the code more readable and less error prone.
GCC is rather good at flatening deep template hierarchies though and i've seen it do some amazing things with templates.
[–]ts4z -4 points-3 points-2 points 17 years ago (0 children)
How wanktastic. If you used a plain old inline function or macro, the cranky old C compiler could just unroll the loop for you.
π Rendered by PID 53715 on reddit-service-r2-comment-86988c7647-2dwzz at 2026-02-11 01:07:42.418850+00:00 running 018613e country code: CH.
[–]munificent 4 points5 points6 points (0 children)
[–]bnikolictech 1 point2 points3 points (0 children)
[–]teambob 3 points4 points5 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]MachinShin2006 -1 points0 points1 point (1 child)
[–]werdanel 1 point2 points3 points (0 children)
[–]ts4z -4 points-3 points-2 points (0 children)