10 ms·
Its an "input only" type, aka don't return it, but use it as an argument
by frozenport 4y ago
Its an "input only" type, aka don't return it, but use it as an argument
- flohofwoe 4y agoThat's just by convention though, right? C++ doesn't prevent me from storing the std::span somewhere so that it outlives the scope of the called function? IMHO it's disappointing that C++ adds new memory management footguns without first fixing the basics (like at least some rudimentary lifetime tracking to help with such situations).
- bartwe 4y agoc# got this right, enforcing the lifetime of Span<>
- BenFrantzDale 4y agoI keep considering writing a `unique_span` and `shared_span`. Really `span` or (a type it’s based on) should have been templated on the pointer type, so a `span<shared_ptr<const T[]>>` for example.
- germandiago 4y agoYes, in C++ you can also do this: ``` int & a = *new int; ``` And it would be as stupid as juggling with spans around liberally.