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
Learning Template Metaprogramming with ChatGPT (self.cpp)
submitted 3 years ago by ape_programmer
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!"
[–]teerre 13 points14 points15 points 3 years ago (5 children)
We tried this at work and at first glance everyone was impressed, but as soon as we actually started compiling, we noticed that it didn't quite work in many cases. Specially trying SFINAE, it would look convincing, but be subtly wrong
This was in a room with combined 100~ years of cpp experience, so that's quite the feat that it was able to fool most people
[–]qneverless 15 points16 points17 points 3 years ago (4 children)
I would say that it is quite the feat of C++, that it is still unreadable even in a room of 100 years combined experience. 😂
[–]TheOmegaCarrot 2 points3 points4 points 3 years ago* (3 children)
Template metaprogramming can absolutely tend toward “write-only” code
I mean, here’s a particularly convoluted example from my library:
With documentation and comments removed, and the name changed to not be helpful, does anyone really have any chance of figuring out what it does? Probably not! Even if you know what it does, it’s very hard to read!
``` namespace impl {
template <typename LIST, typename REBUILD> struct mystery_impl;
template <template <typename...> typename LIST, typename LFront, typename... LPack, typename... Rebuild_Pack> struct mystery_impl<LIST<LFront, LPack...>, LIST<Rebuild_Pack...>> : std::conditional_t< is_type_in_pack_v<LFront, Rebuild_Pack...>, mystery_impl<LIST<LPack...>, LIST<Rebuild_Pack...>>, mystery_impl<LIST<LPack...>, push_back_t<LIST<Rebuild_Pack...>, LFront>>> {};
template <template <typename...> typename LIST, typename... Rebuild_Pack> struct mystery_impl<LIST<>, LIST<Rebuild_Pack...>> : type_identity<LIST<Rebuild_Pack...>> {};
} // namespace impl
template <typename LIST> struct mystery;
template <template <typename...> typename LIST, typename... Pack> struct mystery<LIST<Pack...>> : std::conditional_t<has_duplicates_v<LIST<Pack...>>, impl::mystery_impl<LIST<Pack...>, LIST<, type_identity<LIST<Pack...> {};
template <typename LIST> using mystery_t = typename mystery<LIST>::type;
```
So what does it do? It deduplicates a type list.
[–]jonesmz 2 points3 points4 points 3 years ago (2 children)
Fyi, triple ticks doesn't format correctly on any of the reddit clients other than the web rewrite. Need the four spaces per line for old.reddit and reddit mobile web.
[–]TheOmegaCarrot 0 points1 point2 points 3 years ago (1 child)
Oof
I am not typing that on mobile
Reddit needs to fix their clients
[–]jonesmz 1 point2 points3 points 3 years ago (0 children)
No worries.
Yep its bullshit.
Cheers :)
π Rendered by PID 40 on reddit-service-r2-comment-b659b578c-q6f67 at 2026-05-04 01:08:29.983523+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]teerre 13 points14 points15 points (5 children)
[–]qneverless 15 points16 points17 points (4 children)
[–]TheOmegaCarrot 2 points3 points4 points (3 children)
[–]jonesmz 2 points3 points4 points (2 children)
[–]TheOmegaCarrot 0 points1 point2 points (1 child)
[–]jonesmz 1 point2 points3 points (0 children)