3 ms·
They don't own anything. It's just a pointer and length. They don't allocate/deallocate.
by eco 4y ago
They don't own anything. It's just a pointer and length. They don't allocate/deallocate.
- saagarjha 4y agoI mean clearly something needs to own the buffer for a new string.
- tialaramex 3y agoSure, but that's not the string_view's problem, you can't just make string_views, the string you want to borrow a view into needs to exist first. Imagine you go to a library and insist on borrowing "My Cousin Rachel", but they don't have it. "Oh I don't care whether you have the book, I just want to borrow it" is clearly nonsense. If they don't have it, you can't borrow it.
- saagarjha 3y agoWalter is talking about D, and he said this: > D doesn't distinguish between a string and a string view. In C++ std::string owns the buffer and std::string_view borrows it. If there is no difference between the two in D, then how is this difference bridged?