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 simple example (using version 2.4.2) "fails" when called with -i "42 " (note the extra space at the end of the string), but works fine for e.g. -i " 42" (space before the integer) (and of course for the more natural way of calling it directly with an integer, e.g. -i 42
Is that a feature or a bug ? Knowing that e.g. std::stoi convert both " 42" and "42 " just fine, I'd call it a bug, but there might be something obvious I'm missing here ?
it is mostly on purpose. Internally it uses std::strtoll to do the conversion and it has a check to make sure that is converts the entire string to an integer or other number. std::stoi ignores trailing characters as well so it converts " 523badNUMBER" just as well as "523" This is generally not what is desired, so the general philosophy has been that if it can't use all the characters in the conversion then something is wrong.
The exact question of whether trailing spaces should be allowed is probably debatable.
A very simple example (using version 2.4.2) "fails" when called with
-i "42 "
(note the extra space at the end of the string), but works fine for e.g.-i " 42"
(space before the integer) (and of course for the more natural way of calling it directly with an integer, e.g.-i 42
Is that a feature or a bug ? Knowing that e.g.
std::stoi
convert both " 42" and "42 " just fine, I'd call it a bug, but there might be something obvious I'm missing here ?see e.g. https://godbolt.org/z/jad4MfsKP to run it
The text was updated successfully, but these errors were encountered: