Boost logo

Boost :

From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2019-11-28 14:32:49


Vinnie Falco wrote:
> How about a free function `concat(...)`
> which allows the caller to optionally specify the maximum capacity of
> the resulting string

See also http://open-std.org/JTC1/SC22/WG21/docs/papers/2019/p1228r1.html
IMO, that paper unnecessarily combines string concatenation
with number-formatting, but it is still interesting to look at.
It converts all of its arguments to string_views, sums the
lengths (at run time), allocates a std::string of that length,
and copies the arguments into it. You could extend that to
(a) permit the return type to be specified as an additional
template parameter, and (b) default that return type to a
static_string if the capacities of all the arguments are finite.

Regards, Phil.


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