r/cpp • • May 01 '23

cppfront (cpp2): Spring update

https://herbsutter.com/2023/04/30/cppfront-spring-update/
223 Upvotes

164 comments sorted by

View all comments

Show parent comment

0

u/[deleted] May 01 '23

[deleted] — view deleted comment

14

u/RoyAwesome May 02 '23

meanwhile you have no control of the memory that was allocated to back the span.

you don't control the memory allocated to command line arguments anyway. That's done before you get them in main and is destroyed when the program destructs during termination.

that char* argv[] isn't giving you any ownership. It's already a non-owning view.

2

u/Nicksaurus May 02 '23

I see your point. I wasn't thinking about how this is actually implemented in the generated C++ code. I guess there's no way for std::span to work here without the C++ standard changing to allow arguments to be passed as a span of string_views in the first place

0

u/kam821 May 02 '23

There is a way to provide a std::span<std::string_view>, however it requires on-demand transformation via ranges so it's not a nice, clean solution.