Subject: [Boost-bugs] [Boost C++ Libraries] #10102: dynamic_properties inconsistent usage of lexical_cast and stringstream
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-06-07 11:09:13
#10102: dynamic_properties inconsistent usage of lexical_cast and stringstream
--------------------------------------------+----------------------
Reporter: Sergey Mitsyn <svm at jinr.ru> | Owner: jewillco
Type: Bugs | Status: new
Milestone: To Be Determined | Component: graph
Version: Boost 1.55.0 | Severity: Problem
Keywords: |
--------------------------------------------+----------------------
Hello,
The {{{boost::dynamic_properties}}} is inconsistent with usage of
{{{boost::lexical_cast}}} and {{{std::stringstream}}}. In file
boost\property_map\dynamic_property_map.hpp, the function
{{{
template<typename Value>
inline Value read_value(const std::string& value)
}}}
uses {{{boost::lexical_cast}}}, while
{{{
std::string dynamic_property_map_adaptor::get_string(const any& key)
}}}
uses {{{std::stringstream}}}.
It is a problem, for example, if used together with a BGL's
{{{boost::write_graphvis_dp}}} and {{{boost::read_graphvis}}} if {{{NaN}}}
attribute values are written and read. With {{{std::stringstream}}} on my
machine (Windows 7 + MSVC 12), NaN's are written as {{{"1.#QNAN"}}}, and
lexical_cast produces and consumes {{{nan}}} and {{{NAN}}} [1]. In such
case {{{boost::bad_lexical_cast}}} is thrown whenever read_graphvis is
called for graphviz file containing {{{NaN}}}s.
Modifying {{{dynamic_property_map_adaptor::get_string}}} 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.
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
{{{atof()}}}, which is locale-dependent and feels messy.
[1] see boost/lexical_cast.hpp, function
{{{
template <class CharT, class T>
bool parse_inf_nan(const CharT* begin, const CharT* end, T& value)
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/10102> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC