3 ms·
That'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
by flohofwoe 4y ago
That'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.