
"Eric Lemings" <lemings@roguewave.com> wrote in message
In the Units library, the default value type is (currently) double and the semantics of all arithmetic operations are based on this built-in type. No assumptions are made about semantics, only that the required operations exist for ValueType.
What is the default value type in Quan? I'm guessing it has something to do with a united value or some other manipulation of value semantics within Quan?
You can choose the value_type : #include <quan/length.hpp> ///////NEW!! //only available in the two_param-branch CVS version of Quan #include <boost/numeric/interval.hpp> #include <quan_matters/test/utility/boost_interval.hpp> #include <boost/numeric/interval/io.hpp> ////////////////// #include <iostream> #include <cassert> #include <boost/typeof/typeof.hpp> #include <boost/type_traits/is_same.hpp> int main() { std::cout.precision(32); quan::length::ft qft(3.0); std::cout << "quan qft.numeric_value() = "<< qft.numeric_value() << '\n'; assert((boost::is_same<BOOST_TYPEOF(qft.numeric_value()),double>::value)); assert(qft.numeric_value() ==3.0); quan::length_<float>::ft qft1(3.0f); std::cout << "quan qft1.numeric_value() = "<< qft1.numeric_value() << '\n'; assert( (boost::is_same<BOOST_TYPEOF(qft1.numeric_value()),float>::value)); assert(qft1.numeric_value() ==3.0f); quan::length_<int>::ft qft2(3); std::cout << "quan qft2.numeric_value() = "<< qft2.numeric_value() << '\n'; assert((boost::is_same<BOOST_TYPEOF(qft2.numeric_value()),int>::value)); assert(qft2.numeric_value() ==3); quan::length_<long>::ft qft3(3L); std::cout << "quan qft3.numeric_value() = "<< qft3.numeric_value() << '\n'; assert((boost::is_same<BOOST_TYPEOF(qft3.numeric_value()),long>::value)); assert(qft3.numeric_value() ==3L); quan::length_<unsigned long>::ft qft4(3UL); std::cout << "quan qft4.numeric_value() = "<< qft4.numeric_value() << '\n'; assert((boost::is_same<BOOST_TYPEOF(qft4.numeric_value()),unsigned long>::value)); assert(qft4.numeric_value() ==3UL); quan::length_<signed char>::ft qft5('3'); std::cout << "quan qft5.numeric_value() = "<< qft5.numeric_value() << '\n'; assert((boost::is_same<BOOST_TYPEOF(qft5.numeric_value()),signed char>::value)); assert(qft5.numeric_value() == '3'); quan::length_<unsigned char>::ft qft6('3'); std::cout << "quan qft6.numeric_value() = "<< qft6.numeric_value() << '\n'; assert((boost::is_same<BOOST_TYPEOF(qft6.numeric_value()),unsigned char>::value)); assert(qft6.numeric_value() == '3'); quan::length_<bool>::ft qft7(true); std::cout << "quan qft7.numeric_value() = " << std::boolalpha << qft7.numeric_value() << '\n'; assert((boost::is_same<BOOST_TYPEOF(qft7.numeric_value()),bool>::value)); assert(qft7.numeric_value() == true); //only available in the two_param-branch CVS version of Quan quan::length_<boost::numeric::interval<double> >::ft qft8(boost::numeric::interval<double> (3.)); std::cout << "quan qft8.numeric_value() = " << qft8.numeric_value() <<'\n'; assert((boost::is_same<BOOST_TYPEOF(qft8.numeric_value()),boost::numeric::interval<double>
::value)); assert((qft8.numeric_value() == boost::numeric::interval<double> (3.))); // } output:
E:\projects\Test>testgcc quan qft.numeric_value() = 3 quan qft1.numeric_value() = 3 quan qft2.numeric_value() = 3 quan qft3.numeric_value() = 3 quan qft4.numeric_value() = 3 quan qft5.numeric_value() = 3 quan qft6.numeric_value() = 3 quan qft7.numeric_value() = true quan qft8.numeric_value() = [3,3] E:\projects\Test> ---------------------- regards Andy Little