Why is there no std::stou?

后端 未结 3 1255
时光取名叫无心
时光取名叫无心 2020-12-10 00:31

C++11 added some new string conversion functions:

http://en.cppreference.com/w/cpp/string/basic_string/stoul

It includes stoi (string to int), stol (string t

3条回答
  •  孤街浪徒
    2020-12-10 00:49

    The most pat answer would be that the C library has no corresponding “strtou”, and the C++11 string functions are all just thinly veiled wrappers around the C library functions: The std::sto* functions mirror strto*, and the std::to_string functions use sprintf.


    Edit: As KennyTM points out, both stoi and stol use strtol as the underlying conversion function, but it is still mysterious why while there exists stoul that uses strtoul, there is no corresponding stou.

提交回复
热议问题