Parent Directory
|
Revision Log
work on concept docs
1 #include <quan/meta/mpl/unit.hpp> 2 #include <boost/mpl/vector_c.hpp> 3 #include <boost/mpl/int.hpp> 4 #include <quan_matters/test/concepts/static_unit_concept.hpp> 5 #include <quan/fixed_quantity/operations.hpp> 6 #include <iostream> 7 // demo of using an mpl vector_c for a simple quantity 8 int main() 9 { 10 typedef quan::meta::mpl::unit< 11 boost::mpl::vector_c<int,1,0,0,0,0,0,0,0> 12 > length_unit; 13 14 typedef quan::meta::mpl::unit< 15 boost::mpl::vector_c<int,2,0,0,0,0,0,0,0> 16 > area_unit; 17 // concept checking on units 18 quan::meta::StaticUnitConcept<length_unit>(); 19 quan::meta::StaticUnitConcept<area_unit>(); 20 21 typedef quan::fixed_quantity<length_unit,double> length; 22 typedef quan::fixed_quantity<area_unit,double> area; 23 length length1(1); 24 length length2(2); 25 length length3 =length1 + length2; 26 std::cout << length3.numeric_value() <<'\n'; 27 area a = length1 * length2; 28 std::cout << "length ratio = " << length1 / length2 <<'\n'; 29 std::cout << " area value = " << a.numeric_value() << '\n'; 30 area a2 = quan::pow<2>(length1); 31 // division not available for simple mpl::integral_c types 32 //length length4 = quan::pow<1,2>(a2); 33 34 } 35 36