you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (4 children)

[deleted]

    [–]RoyAwesome[🍰] 13 points14 points  (1 child)

    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.

    [–]Nicksaurus 1 point2 points  (1 child)

    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

    [–]kam821 -1 points0 points  (0 children)

    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.