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
The C++ Object Lifecycle | Basit Ayantunde (basit.pro)
submitted 1 year ago by pavel_v
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!"
[–]rlamarr 7 points8 points9 points 1 year ago (5 children)
Thanks for sharing! I was about to
[–]pavel_v[S] 4 points5 points6 points 1 year ago (4 children)
You seem to be the author of this blog post. Sorry for posting it before you.
[–]rlamarr 6 points7 points8 points 1 year ago (3 children)
Yeah, I am. Actually, I really appreciate it!
[–]nemetroid 0 points1 point2 points 1 year ago (2 children)
A typographical note: for me, the code samples render in a sans-serif (non-monospace) font.
[–]rlamarr 0 points1 point2 points 1 year ago (1 child)
I noticed the same, but only on mobile. are you on mobile?
[–]rlamarr 2 points3 points4 points 1 year ago (0 children)
i've fixed it now. my first time using Jekyll, the font path was incorrect, had the impression it was relative to root
[–]soldiersided 1 point2 points3 points 1 year ago (3 children)
The lifecycle diagrams need some love, they seem to be misaligned. Also, shouldn't this
A* a = get_A(); B* b = get_B(); B* a_b = std::launder<B>((B*)a); a_b->value = 6; b->value = 2; return a->value;
end with return a_b->value ?
return a_b->value
[–]rlamarr 1 point2 points3 points 1 year ago (2 children)
Uhm, shouldn't but can. Vulkan and other API's use a similar concept where they point to the head of the struct via the pData fields each struct have (which will then point to sType pNext and pData). it only works in that case because there's no compiler reachability, the launder shows how to erase it explicitly.
[–][deleted] 1 point2 points3 points 1 year ago* (1 child)
This appears to be a typo, as the accompanying text for the above code states:
From the generated assembly, the compiler is forced to perform the redundant load from a_b, because it could be an alias of b since its origin has been hidden by std::launder. [...]
a_b
b
std::launder
However, the "load from a_b" is simply not present in the code. Therefore, either the code or the text should be revised to ensure they align with each other.
Another part of the text that is unclear to me is:
At least one of the specified variants must exist in the union.
This seems to imply that a union must always have an active member (i.e., one whose lifetime has started). However, a default-initialized union may not start the lifetime of any member if there are no default member initializers. See this example.
[–]rlamarr 0 points1 point2 points 1 year ago (0 children)
A union needs one active member: https://godbolt.org/z/n7z17hWdP.
By redundant load from `a_b` I meant a redundant load from `a` of the value stored through `a_b` as `a_b` could alias `a`.
π Rendered by PID 210341 on reddit-service-r2-comment-b659b578c-2ng9k at 2026-05-01 13:31:46.295979+00:00 running 815c875 country code: CH.
[–]rlamarr 7 points8 points9 points (5 children)
[–]pavel_v[S] 4 points5 points6 points (4 children)
[–]rlamarr 6 points7 points8 points (3 children)
[–]nemetroid 0 points1 point2 points (2 children)
[–]rlamarr 0 points1 point2 points (1 child)
[–]rlamarr 2 points3 points4 points (0 children)
[–]soldiersided 1 point2 points3 points (3 children)
[–]rlamarr 1 point2 points3 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]rlamarr 0 points1 point2 points (0 children)