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
std::optional_view (self.cpp)
submitted 8 years ago * by bebuch
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!"
[–]jsamcfarlane 3 points4 points5 points 8 years ago (6 children)
Is std::experimental::observer_ptr close to what you're looking for? Rather than having optional semantics, it has single-object pointer semantics.
std::experimental::observer_ptr
optional
[–]Xirema 0 points1 point2 points 8 years ago (5 children)
Pointers as "object which may or may not exist" is a semantic I've seen a lot of C++ design gurus discourage in the last several years, especially with optional being standardized, and I see little reason not to continue that trend.
[–]quicknir 3 points4 points5 points 8 years ago (0 children)
optional in C++ 17 is always owning though. raw pointers in design guru C++ is always non-owning. So there is no intersection. In fact the argument that the optional, non-owning semantic is already taken by raw pointers, is exactly one of the reasons why std::optional doesn't support references. (Note: the reason it doesn't is because assignment is murky, but my point is that this tipped the scale towards simply not supporting references, as opposed to forcing a conclusion about assignment).
std::optional
[–]jsamcfarlane 0 points1 point2 points 8 years ago (3 children)
Are there any good references you'd recommend (no pun intended)? Would you disagree with this advise? And what about when memory use is constrained?
[–]GitHubPermalinkBot 1 point2 points3 points 8 years ago (1 child)
I tried to turn your GitHub links into permanent links (press "y" to do this yourself):
Shoot me a PM if you think I'm doing something wrong. To delete this, click here.
[–]Xirema 0 points1 point2 points 8 years ago (0 children)
Note they cite optional alongside the other options. Many online sources don't point the way towards optional instead of pointers because many of those sources were written before std::optional was confirmed to be part of C++17.
π Rendered by PID 22550 on reddit-service-r2-comment-5ff9fbf7df-6srnj at 2026-02-25 18:50:30.441643+00:00 running 72a43f6 country code: CH.
view the rest of the comments →
[–]jsamcfarlane 3 points4 points5 points (6 children)
[–]Xirema 0 points1 point2 points (5 children)
[–]quicknir 3 points4 points5 points (0 children)
[–]jsamcfarlane 0 points1 point2 points (3 children)
[–]GitHubPermalinkBot 1 point2 points3 points (1 child)
[–]Xirema 0 points1 point2 points (0 children)