[units] initialization from zero magic

Hi, I am curious. In Boost.Units it is not possible to *initialize* a quantity from a plain value, the closest thing to it is the ::from_value static member function. But ... What is the magic that makes this particular initialization compile? boost::units::quantitysi::length L(0); //compiles and works as expected but *not* these ones: boost::units::quantitysi::length L(1); //does not compile or boost::units::quantitysi::length L(0.); //does not compile (gives a compile error, "no matching function for call to '...::quantity(int/double)') By the way, I think it is a great feature! I am interested to know how is this achieved. Thanks, Alfredo

On Sun, Jun 13, 2010 at 11:18 PM, alfC
Hi,
I am curious. In Boost.Units it is not possible to *initialize* a quantity from a plain value, the closest thing to it is the ::from_value static member function. But ... What is the magic that makes this particular initialization compile?
boost::units::quantitysi::length L(0); //compiles and works as expected
but *not* these ones:
boost::units::quantitysi::length L(1); //does not compile or boost::units::quantitysi::length L(0.); //does not compile
(gives a compile error, "no matching function for call to '...::quantity(int/double)')
By the way, I think it is a great feature! I am interested to know how is this achieved.
Without looking at the code, my first guess is that it takes a pointer, and you are really passing a null pointer. -- Cory Nelson http://int64.org
participants (2)
-
alfC
-
Cory Nelson