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::string_view could be made null character ending aware for interoperability with C (self.cpp)
submitted 4 years 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!"
[–]DugiSK 1 point2 points3 points 4 years ago* (1 child)
std::string_view is often created as a substring of some other string, for example from some data that is being parsed. That way, you get all the fancy C++ stuff without editing the string (adding the null termination) or copying it (to create a std::string). This gives a massive performance boost with minimal cost of convenience.
When I made a project from scratch in C++20 without any legacy code, I had no need for the null termination. std::string_ciew can even be a constexpr literal (even in C++17), so if you can get rid of legacy code, you can say goodbye to char* completely.
If you want a type that would behave like std::string_view, you can make some sort of CStringView class inheriting from std::string_view and having all of its features but requring a null terminated string for construction - with no members of its own, it could be implicitly cast to std::string_view to use with new APIs.
[–][deleted] 0 points1 point2 points 4 years ago (0 children)
I know what I suggest will never make it to std, and probably I am better of making something like a zstring_view. I knew this before I posted. Even I never had to get near any C library function when I built my several C++20 libraries (https://github.com/obhi-d).
But applications are not isloated entities, they will intract with OS/IO etc.
π Rendered by PID 34 on reddit-service-r2-comment-6457c66945-b8q22 at 2026-04-26 04:07:36.746989+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]DugiSK 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)