28 Nov
2019
28 Nov
'19
2:32 p.m.
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.