I’m using the C++ Units library by Calum Grant http://calumgrant.net/units/ to manage values representing lengths or speeds.
Now I need a unit not specified by this library, and that is feet per minute. According to http://calumgrant.net/units/units.html you can make new units like this:
typedef units::compose< units::units::m, units::pow<units::units::s, -1> > meters_per_second;
but this example doesn’t work. If I specify
typedef units::compose< units::units::foot, units::pow<units::units::minute, -1> >
feet_per_minute;
feet_per_minute vertical_speed(12);
I get the following compile error (using gcc 4.2.1 on Mac)
error: variable 'feet_per_minute vertical_speed' has initializer but incomplete type
and this error when compiling with clang 3
error: implicit instantiation of undefined template 'units::compose<units::scale<units::scale<units::scale<units::units::m, 100, 1>, 100, 254>, 1, 12>, units::pow<units::scale<units::units::s, 1, 60>, -1, 1> >'
What is missing?
Well, I just found the problem. There exist “units” and there exist “values” of those unit. So the correct definition is as follows: