On Tue, Jan 3, 2017 at 1:32 PM, Andrey Semashev
Yes, as manually calling reserve beforehand is always possible. How to optimally implement this is still an open question but that's kind of an implementation detail.
But you would have to either overallocate memory or perform the formatting to determine its length.
True
And while overallocating might be possible for standard types such as integers and FP numbers (assuming C-locale format), that does not seem possible for user's types. Or are you not planning to support user-defined types?
Supporting such types in one big call to sprint would be nice but it does complicate the proposal. One could always call sprint(s, <udt>) 'manually'. Or maybe the two-argument version could be the extension point. Maybe a sprint_max_size(s, <udt>) could be used (if defined) to estimate the size required.
My intent was to format into a local/preallocated buffer, without any additional allocations, but I assume that won't work because `std::array` is lacking APIs for insertion. That probably means that you have to define a concept of the possible target, what operations it must support.
Right, if we opt for a generic version. It would again complicate the proposal though. -- Olaf