Boost C++ Libraries: Ticket #10102: dynamic_properties inconsistent usage of lexical_cast and stringstream https://svn.boost.org/trac10/ticket/10102 <p> Hello, </p> <p> The <code>boost::dynamic_properties</code> is inconsistent with usage of <code>boost::lexical_cast</code> and <code>std::stringstream</code>. In file boost\property_map\dynamic_property_map.hpp, the function </p> <pre class="wiki">template&lt;typename Value&gt; inline Value read_value(const std::string&amp; value) </pre><p> uses <code>boost::lexical_cast</code>, while </p> <pre class="wiki">std::string dynamic_property_map_adaptor::get_string(const any&amp; key) </pre><p> uses <code>std::stringstream</code>. </p> <p> It is a problem, for example, if used together with a BGL's <code>boost::write_graphvis_dp</code> and <code>boost::read_graphvis</code> if <code>NaN</code> attribute values are written and read. With <code>std::stringstream</code> on my machine (Windows 7 + MSVC 12), NaN's are written as <code>"1.#QNAN"</code>, and lexical_cast produces and consumes <code>nan</code> and <code>NAN</code> <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">[1]</a>. In such case <code>boost::bad_lexical_cast</code> is thrown whenever read_graphvis is called for graphviz file containing <code>NaN</code>s. </p> <p> Modifying <code>dynamic_property_map_adaptor::get_string</code> to use boost::lexical_cast seems to fix the issue with graph reading/writing. Though I'm not trying to use such files as an input for graphviz. </p> <p> Speaking about graphviz, docs seem not to define any restrictions on attribute values, and I haven't looked at the source code. Quick googling gave me [http:/_/comments.gmane.org/gmane.comp.video.graphviz/7062], which is not related to this case, but it is stated there that graphviz uses <code>atof()</code>, which is locale-dependent and feels messy. </p> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">[1]</a> see boost/lexical_cast.hpp, function </p> <pre class="wiki">template &lt;class CharT, class T&gt; bool parse_inf_nan(const CharT* begin, const CharT* end, T&amp; value) </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10102 Trac 1.4.3