Why do std::stof, std::stod, and std::stold handle errors with exceptions?
<p>What is the rationale for why <code>std::stof</code>, <code>std::stod</code>, and <code>std::stold</code> throw exceptions?</p>
<p><a href="http://en.cppreference.com/w/cpp/string/basic_string/stof" rel="nofollow noreferrer">http://en.cppreference.com/w/cpp/string/basic_string/stof</a></p>
<p>Input errors are a commonly used example for when error handling via exceptions is a poor fit (usually phrased with the quirky circular reasoning of &quot;exceptional circumstances&quot; but still a good example). It's not as if other error handling mechanisms are somehow verboten in the C++ standard library. For example, another C++11 newcomer, the <code>std::unordered_map::insert</code> family, indicates failure  using the second element in a <code>std::pair&lt;iterator,bool&gt;</code> return type. Failure inside a <code>std::unordered_map::insert</code> function seems much more &quot;exceptional&quot; than an input error. Without attempting to insert, it's possible to guarantee that an insert will succeed but without parsing it's not possible to guarantee that parsing will succeed.</p>
<p>I'm just wondering what the rationale was at the time these functions were accepted into the standard. Hopefully it's published somewhere or a committee member can drop by and shed some light on this. I'm not asking for a comprehensive treatise on the advantages and disadvantages of exceptions vs other mechanisms.</p>