News for hackers. Stuff that matters.
Re:Libc++'s Implementation of std::string by zelly on Thursday January 30, 2020 @11:13PM (#22198974)

    const char& c = a.front();
Unfortunately the STL has an overload for the non-const version, which would cause this problem. It's hard to imagine the cases where you'd need a mutable reference to a single character. It can fit into the same register that the reference would live, so even as an immutable reference it doesn't make much sense.
Re:Libc++'s Implementation of std::string by kccqzy on Friday January 31, 2020 @12:22AM (#22199308)
That's not an answer. The STL has to have a non-const version that returns some kind of reference. Because C++ strings are mutable and even something like

    s[3] = 'h';
involves forming a mutable reference and then assigning its pointee.

The way I think about it, to make CoW strings really usable in C++, you basically have to make strings immutable, like many newer languages like Python. That ship has sailed by the time standardization for C++ happened.

Re:Libc++'s Implementation of std::string by gumby on Friday January 31, 2020 @12:25AM (#22199326)
There’s nothing stopping you from making const strings. That’s why immutable strings are not added.
Re:Libc++'s Implementation of std::string by gpderetta on Friday January 31, 2020 @07:04AM (#22200979)
s[3] could return a proxy though. Probably still not worth the complexity.