Boost C++ Libraries: Ticket #12308: Quantities cannot be sent to std::ostream https://svn.boost.org/trac10/ticket/12308 <p> Compiling the following program </p> <pre class="wiki">#include &lt;iostream&gt; #include "boost/units/systems/si.hpp" #include "boost/units/quantity.hpp" int main() { boost::units::quantity&lt;boost::units::si::electric_potential&gt; quantity = 1 * boost::units::si::volt; std::cout &lt;&lt; quantity; return 0; } </pre><p> that sends a quantity to a std::ostream with operator&lt;&lt; result in the following error message: </p> <pre class="wiki">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&lt;char&gt;}' lvalue to 'std::basic_ostream&lt;char&gt;&amp;&amp;' std::cout &lt;&lt; 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&lt;_CharT, _Traits&gt;&amp; std::operator&lt;&lt;(std::basic_ostream&lt;_CharT, _Traits&gt;&amp;&amp;, const _Tp&amp;) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; _Tp = boost::units::quantity&lt;boost::units::unit&lt;boost::units::list&lt;boost::units::dim&lt;boost::units::length_base_dimension, boost::units::static_rational&lt;2l&gt; &gt;, boost::units::list&lt;boost::units::dim&lt;boost::units::mass_base_dimension, boost::units::static_rational&lt;1l&gt; &gt;, boost::units::list&lt;boost::units::dim&lt;boost::units::time_base_dimension, boost::units::static_rational&lt;-3l&gt; &gt;, boost::units::list&lt;boost::units::dim&lt;boost::units::current_base_dimension, boost::units::static_rational&lt;-1l&gt; &gt;, boost::units::dimensionless_type&gt; &gt; &gt; &gt;, boost::units::homogeneous_system&lt;boost::units::list&lt;boost::units::si::meter_base_unit, boost::units::list&lt;boost::units::scaled_base_unit&lt;boost::units::cgs::gram_base_unit, boost::units::scale&lt;10l, boost::units::static_rational&lt;3l&gt; &gt; &gt;, boost::units::list&lt;boost::units::si::second_base_unit, boost::units::list&lt;boost::units::si::ampere_base_unit, boost::units::list&lt;boost::units::si::kelvin_base_unit, boost::units::list&lt;boost::units::si::mole_base_unit, boost::units::list&lt;boost::units::si::candela_base_unit, boost::units::list&lt;boost::units::angle::radian_base_unit, boost::units::list&lt;boost::units::angle::steradian_base_unit, boost::units::dimensionless_type&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;]' operator&lt;&lt;(basic_ostream&lt;_CharT, _Traits&gt;&amp;&amp; __os, const _Tp&amp; __x) ^ 13:51:56 Build Finished (took 1s.190ms) </pre><p> I got a little nervous when I noticed that old <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6119" title="#6119: Bugs: output streams not working with units (closed: wontfix)">#6119</a> 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. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12308 Trac 1.4.3 Jürgen Hunold Fri, 01 Jul 2016 14:26:51 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/12308#comment:1 https://svn.boost.org/trac10/ticket/12308#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> You are missing </p> <pre class="wiki">#include "boost/units/io.hpp" </pre><p> for this to compile. </p> Ticket