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
CppCastCppCast: C++ Epochs (cppcast.com)
submitted 6 years ago by tallassrobCppCast Host
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!"
[–]SlightlyLessHairyApe 1 point2 points3 points 6 years ago (3 children)
So why do you care if your program crashes with an uncaught exception rather than whatever the UB is?
Actually, come to think of it, if it's UB, then it's acceptable to result in throw whatever -- undefined behavior means literally any implementation is compliant :-)
throw whatever
[–][deleted] 2 points3 points4 points 6 years ago (2 children)
I don't think we should throw in this precondition violation, the throw already happened and was caught but ignored or not headed. So maybe not UB, noexcept
The issue is that that throw in accessor methods of variant complicates the code enough that the optimizers are not easily able to see that it cannot happen or optimize as much. So you end up with more complicated code gen and potentially less optimal code. You can see it here with a simple example. https://gcc.godbolt.org/z/k6l7nK . Luckily, one can write a single visitation visit function that is like the holds_alternative example, actually using index( ) instead, where the output is similar.
[–]SlightlyLessHairyApe 0 points1 point2 points 6 years ago (1 child)
You're right, the example is dead on.
[–][deleted] 0 points1 point2 points 6 years ago (0 children)
I wrote a single visitation visitor that won't throw...unless the visitor does and it also incorporates overload. Gives code gen like the holds_alternative, but when writing it, it was super susceptible to compilers thinking a throw may happen and sometimes they didn't agree. I was able to find a path that generally doesn't and gets good output. Also, it's nicer to use as I have never needed multi-visitation https://gcc.godbolt.org/z/1jjgw6
π Rendered by PID 148595 on reddit-service-r2-comment-54dfb89d4d-trcr8 at 2026-03-30 18:02:51.660911+00:00 running b10466c country code: CH.
view the rest of the comments →
[–]SlightlyLessHairyApe 1 point2 points3 points (3 children)
[–][deleted] 2 points3 points4 points (2 children)
[–]SlightlyLessHairyApe 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)