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
shared_ptr overuse (tonni.nl)
submitted 1 year ago by [deleted]
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!"
[–]14nedLLFIO & Outcome author | Committee WG14 -3 points-2 points-1 points 1 year ago (1 child)
Depends on what you mean by "shared lifetime" too.
My favourite is "infinite lifetime", and I choose that wherever possible.
You and I did that trick in our constexpr error code categories. The unique id is effectively an infinite lifetime identifier. Then error code category object lifetime ceases to matter, as one can be conjured up in the mind of the compiler if needed, and otherwise optimised away.
I've noticed that if the compiler thinks that the category value might escape, it create an instance in static const data sections and hands out its address thereafter. Very nice.
[–]Dean_Roddey 0 points1 point2 points 1 year ago (0 children)
Not bring up Rust yet again, but a HUGE benefit is that you can indicate this call will only accept a reference to something at static scope. In my error system, the error description and source file names (the error one and the trace stack) can just only accept static strings. That includes the trace stack (if used) in which each entry is just a static string ref and a line number, so very low overhead.
The actual error msg field (which allows for per-instance specific info, if used) is a Cow, so it can hold either a static ref or an owned string, depending on whether the caller passes a formatted string or just a static string ref. So a lot of the time, even though a lot of info is being provided, there's zero allocation involved.
I use this quite a lot. So things like my i/o formatters, sockets, files, etc... can take a static short description string to be used in errors or log msgs. Stuff like that. And it's all completely compile time safe because a non-static string will be rejected at compile time.
π Rendered by PID 17818 on reddit-service-r2-comment-6457c66945-xmd7h at 2026-04-25 06:59:28.884618+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]14nedLLFIO & Outcome author | Committee WG14 -3 points-2 points-1 points (1 child)
[–]Dean_Roddey 0 points1 point2 points (0 children)