Boost logo

Boost Users :

Subject: [Boost-users] [units][phoenix] static physical constants don't play well with phoenix?
From: alfC (alfredo.correa_at_[hidden])
Date: 2011-04-30 01:19:37


Hi,

 This post is just to point out a deficiency of either boost.phoenix
or boost.units and see if there are workarounds.

 Phoenix 3 now plays well with Boos.units quantities out of the box
but for some reason it does not play well with boost.units static
physical constants. Like in the following example. This is because the
constant 'hbar' is not a normal quantity type but a
boost::units::constant< ... hbar_t > type. do you think physical
constants could be defined as normal quantities in the future so it
can play well with phoenix?

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

int main(){
        using namespace boost::units;
        using namespace boost::phoenix;
        using namespace boost::phoenix::arg_names;

        quantity<si::action> const hbarvar =
boost::units::si::constants::codata::hbar;
        std::clog << (arg1 * hbarvar)(5.) << std::endl; // works
        std::clog << (arg1 * boost::units::si::constants::codata::hbar)(5.)
<< std::endl; //doesn't work

        return 0;
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net