0

I am trying to get started with Boost.Units and facing the following issue:

#include <boost/units/quantity.hpp>
#include <boost/units/systems/si/prefixes.hpp>
#include <boost/units/systems/si/length.hpp>
using namespace boost::units::si;
using namespace boost::units;

int main()
{
    quantity<length> a(10.0 * centi * meter); //compiles fine
    quantity<length> b = 10.0 * centi * meter; //compiler error
}

The error, due to the templated nature of the library, is very long: error: conversion from 'boost::units::multiply_typeof_helper<boost::units::quantity...

Is this by design, or am I missing something?

matpen
  • 281
  • 2
  • 15
  • There's no implicit conversion defined. This is on purpose. – sehe Jan 31 '16 at 21:18
  • 1
    A link to the FAQ: [Why are conversions explicit by default?](http://www.boost.org/doc/libs/1_60_0/doc/html/boost_units/FAQ.html#boost_units.FAQ.ExplicitConversions) –  Jan 31 '16 at 21:29
  • Thank you, I see now. All conversions must be explicit in order to avoid unintended behaviour. – matpen Feb 04 '16 at 11:20

0 Answers0