Boost logo

Boost :

Subject: Re: [boost] speed of light from universal_constants Boost.Units
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2014-03-10 13:37:41


On 03/10/2014 10:12 AM, Roger Martin wrote:
> I've tried and tried and just not understanding or can't muddle my way
> through the boost units(looks powerful though). For a start, just
> trying to get at the speed of light in
> boost/units/systems/si/codata/universal_constants.hpp
> boost::units::si::constants::codata::c
> boost::units<boost::units::si>::constants::codata::c.value()
> and massive errors; especially if I try to multiplying with something.
> I use boost::math::constants::pi<double>() from
> #include "boost/math/constants/constants.hpp"
> But the universals allude me; and example? where is my brain stuck?

I'm not sure. You'll need to give more details.
(preferable a small /complete/ program that
doesn't compile)

The following seems to work for me. (I did run into
the fact that there's a missing #include <boost/units/quantity.hpp>
in the constants.)

#include <boost/units/quantity.hpp>
#include <boost/units/systems/si/codata_constants.hpp>
#include <boost/units/io.hpp>
#include <iostream>

int main() {
    std::cout << boost::units::si::constants::codata::c * 2.5 << std::endl;

In Christ,
Steven Watanabe

Boost list run by bdawes at, gregod at, cpdaniel at, john at