[Boost-bugs] [Boost C++ Libraries] #12308: Quantities cannot be sent to std::ostream

Subject: [Boost-bugs] [Boost C++ Libraries] #12308: Quantities cannot be sent to std::ostream
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-06-30 11:58:13


#12308: Quantities cannot be sent to std::ostream
---------------------------------------------+-----------------------------
 Reporter: gunnar.arndt@… | Owner: matthiasschabel
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: units
  Version: Boost 1.61.0 | Severity: Showstopper
 Keywords: quantity ostream operator<< g++ |
---------------------------------------------+-----------------------------
 Compiling the following program
 {{{
 #include <iostream>

 #include "boost/units/systems/si.hpp"
 #include "boost/units/quantity.hpp"

 int main() {
     boost::units::quantity<boost::units::si::electric_potential> quantity
 = 1 * boost::units::si::volt;
     std::cout << quantity;
         return 0;
 }

 }}}
 that sends a quantity to a std::ostream with operator<< result in the
 following error message:

 {{{
 13:51:55 **** Incremental Build of configuration Debug for project Test
 ****
 Info: Internal Builder is used for build
 g++ -std=c++0x "-IC:\\firedect\\git\\boost" -O0 -g3 -Wall -c -fmessage-
 length=0 -o "src\\Test.o" "..\\src\\Test.cpp"
 ..\src\Test.cpp: In function 'int main()':
 ..\src\Test.cpp:8:18: error: cannot bind 'std::ostream {aka
 std::basic_ostream<char>}' lvalue to 'std::basic_ostream<char>&&'
      std::cout << quantity;
                   ^
 In file included from
 c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\iostream:39:0,
                  from ..\src\Test.cpp:1:
 c:\mingw\lib\gcc\mingw32\4.9.3\include\c++\ostream:602:5: note:
 initializing argument 1 of 'std::basic_ostream<_CharT, _Traits>&
 std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with
 _CharT = char; _Traits = std::char_traits<char>; _Tp =
 boost::units::quantity<boost::units::unit<boost::units::list<boost::units::dim<boost::units::length_base_dimension,
 boost::units::static_rational<2l> >,
 boost::units::list<boost::units::dim<boost::units::mass_base_dimension,
 boost::units::static_rational<1l> >,
 boost::units::list<boost::units::dim<boost::units::time_base_dimension,
 boost::units::static_rational<-3l> >,
 boost::units::list<boost::units::dim<boost::units::current_base_dimension,
 boost::units::static_rational<-1l> >, boost::units::dimensionless_type> >
> >,
 boost::units::homogeneous_system<boost::units::list<boost::units::si::meter_base_unit,
 boost::units::list<boost::units::scaled_base_unit<boost::units::cgs::gram_base_unit,
 boost::units::scale<10l, boost::units::static_rational<3l> > >,
 boost::units::list<boost::units::si::second_base_unit,
 boost::units::list<boost::units::si::ampere_base_unit,
 boost::units::list<boost::units::si::kelvin_base_unit,
 boost::units::list<boost::units::si::mole_base_unit,
 boost::units::list<boost::units::si::candela_base_unit,
 boost::units::list<boost::units::angle::radian_base_unit,
 boost::units::list<boost::units::angle::steradian_base_unit,
 boost::units::dimensionless_type> > > > > > > > > > > >]'
      operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x)
      ^

 13:51:56 Build Finished (took 1s.190ms)
 }}}
 I got a little nervous when I noticed that old #6119 seems to describe the
 same problem, although I don't get what it has to do with Intel and
 Leopard?
 I hope I've just made a stupid mistake in my code.

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