Re: [Boost-bugs] [Boost C++ Libraries] #11800: Boost Convert fails on user defined types with no value_type

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #11800: Boost Convert fails on user defined types with no value_type
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-11-18 01:50:45


#11800: Boost Convert fails on user defined types with no value_type
------------------------------------+---------------------
  Reporter: Brad Anderson <eco@…> | Owner:
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: None
   Version: Boost 1.59.0 | Severity: Problem
Resolution: | Keywords:
------------------------------------+---------------------

Comment (by Brad Anderson <eco@…>):

 Here is a reproducible using a slightly modified version of the example
 included with boost convert.

 {{{

 #include <boost/convert.hpp>
 #include <boost/convert/stream.hpp>

 //#define VALUE_TYPE value_type
 #define VALUE_TYPE type

 struct change
 {
     enum VALUE_TYPE { no, up, dn };

     change(VALUE_TYPE v =no) : value_(v) {}
     bool operator==(change v) const { return value_ == v.value_; }
     VALUE_TYPE value() const { return value_; }

     private: VALUE_TYPE value_;
 };

 std::istream& operator>>(std::istream& stream, change& chg)
 {
     std::string str; stream >> str;

     /**/ if (str == "up") chg = change::up;
     else if (str == "dn") chg = change::dn;
     else if (str == "no") chg = change::no;
     else stream.setstate(std::ios_base::failbit);

     return stream;
 }

 std::ostream& operator<<(std::ostream& stream, change const& chg)
 {
     return stream << (chg == change::up ? "up" : chg == change::dn ? "dn"
 : "no");
 }

 int main()
 {
     boost::cnv::cstream cnv;
     boost::convert<std::string>(change(change::up), cnv);
 }

 }}}

 The original uses `value_type` but if you change it to something else (as
 I've done here) you'll get the compilation error in MSVC 2013.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11800#comment:2>
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:19 UTC