Namespaces
Variants
Actions

Talk:cpp/utility/from chars

From cppreference.com

[edit] Whitespaces

The C++ standard states that

> The pattern is the expected form of the subject sequence [...], as described for strtol/strtod [...]. [1]

cppreference states that

> Expects the pattern identical to the one used by std::strtol [...]

I believe that this is an incorrect simplification. For strtol/strtod subject sequence is the second part of the pattern. [2] The simplification neglects that strtol/strtod ignore leading whitespace characters. I recommend to add a point to the two "except that" lists: "... leading whitespaces are not ignored".

Merged, thanks --Ybab321 (talk) 08:59, 21 September 2021 (PDT)

[edit] Complexity

Does the standard guarantee that this is an O(1) operation? BenFrantzDale (talk) 04:27, 4 March 2021 (PST)

[edit] Example correction

Suggested fix to example code:

FROM: if(auto [p, ec] = std::from_chars(sv.begin(), sv.end(), result);

TO: if(auto [p, ec] = std::from_chars(sv.data(), sv.data() + sv.size(), result);

Currently these iterators have issues with from_chars.

See: https://github.com/cplusplus/papers/issues/744

192.182.150.63 11:38, 30 April 2021 (PDT)Rich

Updated. p2007r0. Thank you. --Space Mission (talk) 14:37, 30 April 2021 (PDT)