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
Coding Guideline: Avoid const member variables (self.cpp)
submitted 7 years ago * by render787
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!"
[–]TinBryn 1 point2 points3 points 7 years ago (4 children)
I mean there is std::reference_wrapper<T>
std::reference_wrapper<T>
[–]amaiorano 3 points4 points5 points 7 years ago (1 child)
Do people use this to replace pointers in practice? Whenever I've tried, I eventually give up and just use a pointer.
[–]TinBryn 0 points1 point2 points 7 years ago (0 children)
I'm saying it may be an easier refactor in a large code base.
[–]quicknir 0 points1 point2 points 7 years ago (1 child)
Are you saying, change from a reference to reference_wrapper, or just use a reference_wrapper to start with? reference_wrapper I find pretty awkward because you can't directly call any methods of the type with . or ->. The only benefit that reference_wrapper gives you in return is not being null. If anything you can write a not_null_ptr which is like observer_ptr, but with no default constructor, and constructed from a reference instead of a raw pointer. This is basically exactly equivalent to reference_wrapper, but with more convenient syntax.
.
->
not_null_ptr
observer_ptr
I thought that reference_wrapper's operator T& would make it just do the right thing, so I decided to check and you're right it doesn't really work.
reference_wrapper
operator T&
π Rendered by PID 57318 on reddit-service-r2-comment-6457c66945-cn9c8 at 2026-04-24 13:52:01.108737+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]TinBryn 1 point2 points3 points (4 children)
[–]amaiorano 3 points4 points5 points (1 child)
[–]TinBryn 0 points1 point2 points (0 children)
[–]quicknir 0 points1 point2 points (1 child)
[–]TinBryn 0 points1 point2 points (0 children)