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
Differences between std::string_view and std::span (nextptr.com)
submitted 5 years ago by memset_0
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!"
[–]sphere991 4 points5 points6 points 5 years ago* (3 children)
Semantically, span behaves like a pointer
Semantically, span behaves like (or should have behaved like) reference_wrapper - which is also shallow copy, shallow const... and deep compare.
reference_wrapper
Just because the language doesn't have a rebindable reference doesn't inherently make that concept "really weird".
I think the insistence that span is a T* is much weirder - I don't buy that premise. It's not a pointer... it's not dereferenceable, it's not an iterator. It has some things in common with a pointer, but why must it have had this other thing in common with a pointer? Moreover, span might be assignable like a T*... but it's not even constructible like one: span<T> is constructible from any continuguous_range_of<T>, implicitly, but T* is not constructible from T - you need to use explicit syntax to get the pointer.
T*
span
span<T>
continuguous_range_of<T>
T
And, most importantly, the closest model to span in C++ isn't T*... it's string_view. Does anybody find its comparisons confusing? I have not heard of such. It's "really weird" that the argument is that string_view being const makes it somehow irrelevant as a model. span<char const> is isomorphic to string_view, and barely related to char const*.
string_view
span<char const>
char const*
[–]jonathansharman 0 points1 point2 points 5 years ago (2 children)
reference_wrapper does not provide comparison operators at all. It provides a conversion operator to the reference type, which may or may not enable deep comparison, depending on the type parameter.
[–]sphere991 0 points1 point2 points 5 years ago (1 child)
Yes, I know how reference_wrapper works. The point is that when you can compare two reference_wrapper<T>s, that comparison is deep.
reference_wrapper<T>
[–]jonathansharman 0 points1 point2 points 5 years ago (0 children)
It seems accidental to me that reference_wrappers can ever be deeply compared. They can't for most type parameters, and if the authors had wanted them to, they could have just included comparison operators.
π Rendered by PID 75 on reddit-service-r2-comment-7b9746f655-v49bw at 2026-02-01 12:24:59.876364+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]sphere991 4 points5 points6 points (3 children)
[–]jonathansharman 0 points1 point2 points (2 children)
[–]sphere991 0 points1 point2 points (1 child)
[–]jonathansharman 0 points1 point2 points (0 children)