Boost C++ Libraries: Ticket #12766: Boost Units: Quantities in Constexpr Functions https://svn.boost.org/trac10/ticket/12766 <p> I would like to use boost quantities in C++11 constexpr functions (and later C++14 constexpr functions). Unfurtunately, I can not define a simple quantity as constexpr: </p> <pre class="wiki">#include &lt;boost/units/systems/si.hpp&gt; #include &lt;boost/units/quantity.hpp&gt; using namespace boost::units; constexpr quantity&lt; si::length, double &gt; dtestExt{ 0.2e-6 }; // or constexpr quantity&lt; si::length, double &gt; dtestExt = 0.2e-6; </pre><p> g++ -std=c++11 (4.9.4): </p> <pre class="wiki">error: the type ‘ const 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;1l&gt; &gt;, boost::units::dimensionless_type &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;’ of constexpr variable ‘dtestExt’ is not literal </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12766 Trac 1.4.3 Jürgen Hunold Fri, 20 Jan 2017 07:30:49 GMT owner changed https://svn.boost.org/trac10/ticket/12766#comment:1 https://svn.boost.org/trac10/ticket/12766#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Matthias Schabel</span> to <span class="trac-author">Jürgen Hunold</span> </li> </ul> <p> This might be solved by <a class="ext-link" href="https://github.com/boostorg/units/pull/22"><span class="icon">​</span>https://github.com/boostorg/units/pull/22</a> which unfortunately is missing tests. </p> Ticket