June 2025
Intermediate to advanced
1093 pages
33h 24m
English
There are many ways to convert a string (or char*) into a number. With C++17, there is another option: from_chars from the <charconv> header. The main focus of from_chars is on performance, as it becomes increasingly important with the growing number of XML and JSON applications.
from_chars comes with the conversion function to_chars for converting numbers to strings.
from_chars shows its strengths when you have a char*, already know that you need to parse a number, and have nothing to do with locales (different decimal and thousand separators) and encodings (UTF-16, etc.).
The existing ways to convert a string to an int or the like include the following:
sscanfFrom C; flexible, related to printf ...
Read now
Unlock full access