Why is there no std :: from_string ()?

Why not

template <typename T>
T std::from_string(const std::string& s);

in the C ++ standard? (Seeing how there is a function std::to_string(), I mean)

PS. If you have an idea for a reason that has not been accepted / considered, just reply / comment and say what it is, not downvoting. In fact, I do not propose that this be included in the standard.

+4
source share
2 answers

, to_string , . , , , . , from_string, , , . (std::string), . , stoi, stof .. , .

to_string sto* : C. ++ IOStreams, , C. , , ++ ​​ std::locale::global imbue d .

+2

std::to_string() : , , . , .

std::from_string() . , , .. , , .

+1

Source: https://habr.com/ru/post/1652617/


All Articles