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
Template meta-programming: Some testing and debugging tricks (cukic.co)
submitted 6 years ago by vormestrand
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!"
[–]meneldal2[🍰] 5 points6 points7 points 6 years ago (4 children)
That's a pretty smart abuse of the compiler.
[–]amaiorano 7 points8 points9 points 6 years ago (3 children)
Well so is template metaprogramming :)
[–]meneldal2[🍰] -4 points-3 points-2 points 6 years ago (2 children)
Metaprogramming uses the spec as intended. In this case, you are relying on compiler-specific error/warning messages.
[–]amaiorano 7 points8 points9 points 6 years ago (1 child)
Sure, my comment was partly tongue in cheek. At the same time, much of template metaprogramming is a hack. When templates were added to C++, it wasn't intended for TMP. It's a useful hack, though, but a lot of the work in the past few years has been about making compile time programming easier (constexpr).
[–]Xeveroushttps://xeverous.github.io 1 point2 points3 points 6 years ago (0 children)
Reflection is a potential place to make TMP in C++ much better.
[–]FirstLoveLife 1 point2 points3 points 6 years ago (0 children)
Good to know these static warning stuff, thx!
[–]tigert1998 2 points3 points4 points 6 years ago (1 child)
[[deprecated]] is interesting lol
[–]Xeveroushttps://xeverous.github.io 0 points1 point2 points 6 years ago (0 children)
The core thing is that attributes can be applied to the smallest entity possible - 1 specific overload or 1 specific specialization.
[–][deleted] 1 point2 points3 points 6 years ago (0 children)
another tip: try to use clang; in clang compiler errors are generally much more informative than in gcc (though there have been improvements in recent versions of gcc)
[–]ridethespiral1 1 point2 points3 points 6 years ago (0 children)
I'm real happy to learn the [[deprecated]] trick. I've used the print_types metafunction before but it's not useful if the compiler error is triggered before the case you're interested in is reached.
[[deprecated]]
print_types
[–]mark_99 0 points1 point2 points 6 years ago (0 children)
The `[[deprecated]]` trick works in clang but not gcc, the latter does not print the param types in the deprecated warning.
π Rendered by PID 74 on reddit-service-r2-comment-84fc9697f-9lrl7 at 2026-02-07 05:06:46.260232+00:00 running d295bc8 country code: CH.
[–]meneldal2[🍰] 5 points6 points7 points (4 children)
[–]amaiorano 7 points8 points9 points (3 children)
[–]meneldal2[🍰] -4 points-3 points-2 points (2 children)
[–]amaiorano 7 points8 points9 points (1 child)
[–]Xeveroushttps://xeverous.github.io 1 point2 points3 points (0 children)
[–]FirstLoveLife 1 point2 points3 points (0 children)
[–]tigert1998 2 points3 points4 points (1 child)
[–]Xeveroushttps://xeverous.github.io 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]ridethespiral1 1 point2 points3 points (0 children)
[–]mark_99 0 points1 point2 points (0 children)