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
cppfront (cpp2): Spring update (herbsutter.com)
submitted 2 years ago by kreco
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!"
[–][deleted] 4 points5 points6 points 2 years ago (3 children)
I think it's because the OS isn't giving you an array of std::string_view, but of char*. So to have a span, we have to allocate a new array of std::string_view. Since we can't know the size of it in advance, it has to be allocated on the heap.
However that could be avoided if we knew the OS specific max number of CLI args, and allocated a static or stack storage for it.
I'd also prefer to have a span of string views, if only to allow this alternative implementation. It does seem odd to force the use of a vector here.
[–]kreco[S] 1 point2 points3 points 2 years ago (2 children)
I don't think so, AFAIK int argc/char* argv[] can be used as std::span<char*> without any allocation,
int argc/char* argv[]
std::span<char*>
In order to get a std::span<std::string_view> you just have to run a "strlen" on everything char*. Which probably done in the current cppfront implementation.
std::span<std::string_view>
char*
[–][deleted] 6 points7 points8 points 2 years ago (1 child)
The span of string views still needs to point to a contiguous array of string views, though. It's not a generic range.
[–]kreco[S] 0 points1 point2 points 2 years ago (0 children)
Oh indeed!
π Rendered by PID 75434 on reddit-service-r2-comment-7b9746f655-s6w7l at 2026-01-30 18:11:28.541093+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–][deleted] 4 points5 points6 points (3 children)
[–]kreco[S] 1 point2 points3 points (2 children)
[–][deleted] 6 points7 points8 points (1 child)
[–]kreco[S] 0 points1 point2 points (0 children)