Re:C Strings and my slow descent to madness
by saagarjha on Friday April 07, 2023 @03:46AM
(#35479218)
I mean clearly something needs to own the buffer for a new string.
[ Parent
| on HN ]
Re:C Strings and my slow descent to madness
by tialaramex on Monday April 17, 2023 @06:08AM
(#35598772)
Sure, 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.
Re:C Strings and my slow descent to madness
by saagarjha on Thursday April 20, 2023 @05:07AM
(#35637794)
Walter 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?