Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2021-10-21 00:42:21


Ahmed Charles wrote:
> On Friday, October 15th, 2021 at 5:14 AM, Phil Endecott via Boost
> <boost_at_[hidden]> 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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk