Hi Robert,
Robert Ramey wrote:
it looks like I'm missing something; Here is the test program again - with
all the headers.
#include
#include
#include
int main(int argc, char * argv[]){
using namespace boost::units;
using namespace boost::units::si;
using namespace boost::units::us;
quantity l1;
l1 = 1.0 * meters;
quantity l2;
l2 = static_cast >(1.0 * miles);
quantity l3 = l1 + l2;
return 0;
}
Just in case you haven't gotten this yet, here's something that compiles
and runs (with g++):
#include
#include
#include
#include
#include
#include <iostream>
namespace boost { namespace units { namespace us
{
typedef boost::units::make_systemboost::units::us::mile_base_unit::type
mile_system;
typedef boost::units::unitboost::units::length_dimension,mile_system
mile_length;
BOOST_UNITS_STATIC_CONSTANT(mile, mile_length);
BOOST_UNITS_STATIC_CONSTANT(miles, mile_length);
}}}
int main(){
using namespace boost::units;
using namespace boost::units::si;
using namespace boost::units::us;
quantity l1;
l1 = 1000.f * meters;
quantity l2;
l2 = static_cast >(1.f * miles);
quantity l3 = l1 + l2;
std::cout << l3 << std::endl;
}
//Outputs 2609.34 m
The key is that value times unit = quantity, but you can't create a unit
from a base_unit without a system. (There doesn't appear to be a system
which declares mile units definitions, as you already found, I think.)
Unfortunately, any other base_units which aren't used in the systems folder
will require similar boilerplate.
HTH,
Nate