21 Oct
2021
21 Oct
'21
12:42 a.m.
Ahmed Charles wrote:
On Friday, October 15th, 2021 at 5:14 AM, Phil Endecott via Boost
wrote: Exactly, it's like returning a string_view from a function - which you should never do, at least not without an obvious indication...
My primary objection to this line of thinking is that the standard begin/end functions have the same dangerous implications as this function does. The input can be a string and the output is something that becomes invalid when that string is destroyed.
begin/end don't have this problem in practice because you need to call both, and that's hard to do on the same temporary. c_str does, but virtually nobody makes this mistake for some reason.