
"Janek Kozicki" <janek_listy@wp.pl> wrote in message news:20060608181103.22f78f81@absurd...
Carlo Wood said: (by the date of Thu, 8 Jun 2006 16:06:47 +0200)
std::cout << pqs::ios::litres << volume;
outputting 'litre' instead of 'm3', but the number of possible formats are endless, and so are the preferences of different people.
Im accustomed to using decimetre^3, always abbreviated as dm^3, which equals exactly 1 litre (because it's 10x10x10 centimeters = 1x1x1 decimeter )
Although liter is equivalent to 1 dm^3, technically its not an SI unit. Its not in the review version of PQS, but it is possible to add a liter unit to volume header and get output as 1 L or whatever is preferred... I just did this in my local version of PQS. The sequence of steps is 1) In <boost/pqs/meta/components/of_volume.hpp> Add a typedef for the liter in the incoherent_unit struct (starts at line 47). typedef meta::unit< boost::pqs::meta::rational<-3>, meta::rational<1>::type, boost::mpl::int_<1> > liter; 2) In <boost/pqs/t1_quantity/types/volume.hpp> Add the typedef for liter to the other member typedefs: typedef t1_quantity< type, typename incoherent_unit::liter, Value_type > liter; 3) In <boost/pqs/t1_quantity/types/out/volume.hpp> add the stream output overload for the liter unit: inline std::ostream& operator <<( std::ostream & os, t1_quantity_units_out< meta::components::of_volume::type, meta::components::of_volume::incoherent_unit::liter > ) { os << "L"; return os; } Check it works: #include <boost/pqs/t1_quantity/types/out/volume.hpp> using boost::pqs::volume; int main() { volume::liter v(1); std::cout << v <<'\n'; volume::m3 v1 = v; std::cout << v1 <<'\n'; } Outputs: 1 L 0.001 m3 Because liter isnt an SI unit you would need to add cL and mL in the same way (I guess that would be the next question!) regards Andy Little