Core C++ 2021 :: The many faces of Number -- String conversions

preview_player
Показать описание
By Dvir Yitzchaki, presented at Core C++ 2021 Conference.

C++ inherited several library functions from C dealing with such conversions and has kept adding more on almost every new standard, the latest examples being to/from_chars from C++17 and C++20’s format library. This didn’t stop non-standard libraries, like Boost, from offering even more ways to do those conversions.

In this talk we will explore
* std::atoi
* std::sprintf
* std::stoi
* std::to_string
* std::from_chars
* boost::lexical_cast
* scn::scan
and more. We will try to understand why the number-string conversion problem is being solved repeatedly, compare the API, implementation and performance of these utilities and if time allows, see how different languages deal with this task.

=====

Dvir is a senior software engineer at Verizon Media/Yahoo, where he works on Video streaming solutions. Part of the Israeli ISO C++ national body. Loves everything that starts with C: Core C++ Conan CMake Catch CI CD and Chubby Checker.
Рекомендации по теме
Комментарии
Автор

Number-String conversions are one of the most important things that pretty much every programmer will use, and the standard provides so many bad ways to do it. Most of the issues would be overcome if they just implemented a decimal type, which is what most people actually need for business logic. Also, if string size is known at compile time, and you are guaranteed only 0-9 characters, rolling your own template is twice as fast as from_chars

KillerMZE