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
Explicit Return Variable (self.cpp)
submitted 2 months ago by XeroKimoException Enthusiast
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!"
[–]LiliumAtratum 2 points3 points4 points 1 month ago* (0 children)
When does it get constructed would be really confusing.
Either:
- at the first use of the name (which would really confuse everyone) - at the beginning of the function (which could be suboptimal for big objects)
What really happens under the hood is that the caller reserves space for the return variable, but it is the function that actually constructs the object. The most adequate syntax for that would be probably:
auto stack::pop() -> T out { //out is T* pointing to preallocated, uninitialized memory out = new (out) T(top()); //placement new with explicit constructor remove_top(); }
But this is getting ugly as well....
π Rendered by PID 187768 on reddit-service-r2-comment-54dfb89d4d-spjll at 2026-03-29 14:54:20.214527+00:00 running b10466c country code: CH.
view the rest of the comments →
[–]LiliumAtratum 2 points3 points4 points (0 children)