[Boost-bugs] [Boost C++ Libraries] #4009: lexical_cast to multimember object fails

Subject: [Boost-bugs] [Boost C++ Libraries] #4009: lexical_cast to multimember object fails
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-03-14 17:33:26

#4009: lexical_cast to multimember object fails
 Reporter: Darko Veberic <darko.veberic@…> | Owner: nasonov
     Type: Bugs | Status: new
Milestone: Boost 1.43.0 | Component: lexical_cast
  Version: Boost 1.40.0 | Severity: Showstopper
 Keywords: |
 According to the documentation, the only relevant requirement for the
 lexical_cast<target>(source) is that the target is input-streamable.
 Having a simple class
 struct Foo {
   int fA;
   int fB;
 with input operator
 operator>>(istream& is, Foo& f)
   return is >> f.fA >> f.fB;
 should satisfy all the requirements. Nevertheless, the code
 const string s = "137 13";
 const Foo f = lexical_cast<Foo>(s);
 compiles without any warnings (g++ 4.4.1) but eventually throws a
 bad_lexical_cast exception. Of course, using a non-optimized non-boost
 version of the lexical cast
 template<typename T, typename U>
 LexicalCast(const U& u)
   stringstream ss;
   ss << u;
   T t;
   if (ss >> t)
     return t;
     throw bad_lexical_cast();
 works fine for the class in the example above. Are there additional
 requirements on the target type that are not mentioned in the
 documentation or is this a really severe bug?

Ticket URL: <https://svn.boost.org/trac/boost/ticket/4009>
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:02 UTC