You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A very common usage pattern of such functions is the following
// the output buffer; could be another type, eg char*
std::string s;
// how large is enough? We can never 100% sure in advance// that the buffer size is enough for a safe write
s.resize(5);
// s is not enough for this:float value = 1234567.f;
// So make s2f() aware of how much space we can write on.// The requested function receives how large the write buffer is,// so it can safely stop writing to it when the space is exhausted,// but does not return and in fact proceeds// through the algorithm /as if/ if it was writing, so it can find the needed size,// which would be the return value:int needed_size = f2s_buffered_sz(value, s.data(), (int)s.size());
// With this we now know the needed size, so we call the function again if the// buffer was not large enough:if(needed_size >= (int)s.size()) {
s.resize(needed_size + 1);
needed_size = f2s_buffered_sz(value, s.data(), (int)s.size());
assert(needed_size < s.size()); // there!
}
But to have this, we would require a version of such functions taking the buffer size and returning the required size.
Would you be open to a PR for this feature?
The text was updated successfully, but these errors were encountered:
biojppm
added a commit
to biojppm/ryu
that referenced
this issue
Oct 12, 2020
A very common usage pattern of such functions is the following
But to have this, we would require a version of such functions taking the buffer size and returning the required size.
Would you be open to a PR for this feature?
The text was updated successfully, but these errors were encountered: