|
Boost Users : |
Subject: [Boost-users] Order of composite units in the output
From: Esben Mose Hansen (boost_at_[hidden])
Date: 2009-02-18 06:09:55
Hi,
I think I am beginning to get the boost:units library, but I still have one
problem. Consider:
#include <iostream>
#include <boost/units/io.hpp>
#include <boost/units/systems/si/length.hpp>
#include <boost/units/make_system.hpp>
#include <boost/units/quantity.hpp>
#include <boost/units/base_dimension.hpp>
#include <boost/units/base_unit.hpp>
#include <boost/units/derived_dimension.hpp>
// Introduce slot (measured in e.g. ffe or tfe) as a basic dimension, unit and
in a system
struct slot_base_dimension :
boost::units::base_dimension<slot_base_dimension, 1>
{ };
typedef slot_base_dimension::dimension_type slot_dimension;
struct ffe_base_unit : public boost::units::base_unit<ffe_base_unit,
slot_dimension, 1>
{
static std::string name() { return("40ft equivalent"); }
static std::string symbol() { return("ffe"); }
};
typedef ffe_base_unit::unit_type slot_t;
BOOST_UNITS_STATIC_CONSTANT(ffe, slot_t);
/// derived dimension (slot) flow
typedef
boost::units::derived_dimension<slot_base_dimension,1,boost::units::time_base_dimension,-1>::type
flow_dimension;
/// placeholder class defining si unit system
typedef boost::units::make_system<boost::units::si::meter_base_unit,
boost::units::si::second_base_unit,
ffe_base_unit>::type unit_system;
typedef boost::units::unit<flow_dimension,unit_system> flow_t;
BOOST_UNITS_STATIC_CONSTANT(ffe_per_second, flow_t);
int main() {
boost::units::quantity<flow_t> flow(4*ffe_per_second);
std::cout << "flow= " << flow << std::endl;
}
This program outputs
flow= 4 s^-1 ffe
which is correct, but a bit unusual... 4 ffe/s or even 4 ffe s^-1 would have
been better. Is this possible?
Thanks!
-- kind regards, Esben
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