Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2019-11-29 08:12:42


> and yes, you can write code that will be correct if op+= doesn't check.

Maybe you can, but I apparently can't. This is what I just wrote:

void my_append( fixed_string<512> & s, std::string_view s1, std::string_view
s2 )
{
    if( s.size() + s1.size() + s2.size() > s.max_size() ) throw
std::length_error( "" );

    s += s1;
    s += s2;
}

Is this correct? (Spoiler: no.)


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