// Test the abs algorithm on the std::complex type #include #include namespace glas { template struct abs_functor< boost::rational > { typedef boost::rational argument_type ; typedef boost::rational result_type ; inline result_type operator() ( argument_type const& v ) const { return boost::abs( v ) ; } }; } // namespace glas int main() { boost::rational a(3,-5) ; boost::rational abs_a = glas::abs( a ) ; double d_abs_a = boost::rational_cast(abs_a) ; if (d_abs_a > 0.599999 && d_abs_a < 6.000001 ) return 0 ; else return 1 ; }