/* Checked_Number class implementation: inline functions. Copyright (C) 2001-2010 Roberto Bagnara Copyright (C) 2010-2011 BUGSENG srl (http://bugseng.com) This file is part of the Parma Polyhedra Library (PPL). The PPL is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. The PPL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. For the most up-to-date information see the Parma Polyhedra Library site: http://www.cs.unipr.it/ppl/ . */ #ifndef PPL_Checked_Number_inlines_hh #define PPL_Checked_Number_inlines_hh 1 #include "globals.defs.hh" #include #include namespace Parma_Polyhedra_Library { #ifndef NDEBUG #define DEBUG_ROUND_NOT_NEEDED #endif inline Rounding_Dir rounding_dir(Rounding_Dir dir) { if (dir == ROUND_NOT_NEEDED) { #ifdef DEBUG_ROUND_NOT_NEEDED return ROUND_CHECK; #endif } return dir; } inline Result check_result(Result r, Rounding_Dir dir) { if (dir == ROUND_NOT_NEEDED) { #ifdef DEBUG_ROUND_NOT_NEEDED PPL_ASSERT(result_relation(r) == VR_EQ); #endif return r; } return r; } template inline void Checked_Number_Transparent_Policy::handle_result(Result) { } inline void Extended_Number_Policy::handle_result(Result r) { if (result_class(r) == VC_NAN) throw_result_exception(r); } template inline Checked_Number::Checked_Number() : v(0) { } template inline Checked_Number::Checked_Number(const Checked_Number& y) { // TODO: avoid default construction of value member. Checked::copy(v, y.raw_value()); } template template inline Checked_Number ::Checked_Number(const Checked_Number& y, Rounding_Dir dir) { // TODO: avoid default construction of value member. Policy::handle_result(check_result(Checked::assign_ext (v, y.raw_value(), rounding_dir(dir)), dir) ); } template template inline Checked_Number ::Checked_Number(const Checked_Number& y) { // TODO: avoid default construction of value member. Rounding_Dir dir = Policy::ROUND_DEFAULT_CONSTRUCTOR; Policy::handle_result(check_result(Checked::assign_ext (v, y.raw_value(), rounding_dir(dir)), dir)); } // TODO: avoid default construction of value member. #define PPL_DEFINE_CTOR(type) \ template \ inline \ Checked_Number::Checked_Number(const type x, Rounding_Dir dir) { \ Policy::handle_result \ (check_result(Checked::assign_ext > \ (v, x, rounding_dir(dir)), \ dir)); \ } \ template \ inline \ Checked_Number::Checked_Number(const type x) { \ Rounding_Dir dir = Policy::ROUND_DEFAULT_CONSTRUCTOR; \ Policy::handle_result \ (check_result(Checked::assign_ext > \ (v, x, rounding_dir(dir)), \ dir)); \ } #define PPL_COND_0(...) #define PPL_COND_1(...) __VA_ARGS__ #define PPL_COND_(if, ...) PPL_COND_##if(__VA_ARGS__) #define PPL_COND(if, ...) PPL_COND_(if, __VA_ARGS__) PPL_DEFINE_CTOR(char) PPL_DEFINE_CTOR(signed char) PPL_DEFINE_CTOR(signed short) PPL_DEFINE_CTOR(signed int) PPL_DEFINE_CTOR(signed long) PPL_DEFINE_CTOR(signed long long) PPL_DEFINE_CTOR(unsigned char) PPL_DEFINE_CTOR(unsigned short) PPL_DEFINE_CTOR(unsigned int) PPL_DEFINE_CTOR(unsigned long) PPL_DEFINE_CTOR(unsigned long long) PPL_COND(PPL_SUPPORTED_FLOAT, PPL_DEFINE_CTOR(float)) PPL_COND(PPL_SUPPORTED_DOUBLE, PPL_DEFINE_CTOR(double)) PPL_COND(PPL_SUPPORTED_LONG_DOUBLE, PPL_DEFINE_CTOR(long double)) PPL_DEFINE_CTOR(mpq_class&) PPL_DEFINE_CTOR(mpz_class&) #undef PPL_DEFINE_CTOR #undef PPL_COND #undef PPL_COND_ #undef PPL_COND_1 #undef PPL_COND_0 template inline Checked_Number::Checked_Number(const char* x, Rounding_Dir dir) { std::istringstream s(x); Policy::handle_result(check_result(Checked::input(v, s, rounding_dir(dir)), dir)); } template inline Checked_Number::Checked_Number(const char* x) { std::istringstream s(x); Rounding_Dir dir = Policy::ROUND_DEFAULT_CONSTRUCTOR; Policy::handle_result(check_result(Checked::input(v, s, rounding_dir(dir)), dir)); } template template inline Checked_Number::Checked_Number(const From&, Rounding_Dir dir, typename Enable_If::value, bool>::type) { Policy::handle_result(check_result(Checked::assign_special(v, From::vclass, rounding_dir(dir)), dir)); } template template inline Checked_Number::Checked_Number(const From&, typename Enable_If::value, bool>::type) { Rounding_Dir dir = Policy::ROUND_DEFAULT_CONSTRUCTOR; Policy::handle_result(check_result(Checked::assign_special(v, From::vclass, rounding_dir(dir)), dir)); } template inline typename Enable_If::value && Is_Special::value, Result>::type assign_r(To& to, const From&, Rounding_Dir dir) { return check_result(Checked::assign_special ::Policy>(Native_Checked_To_Wrapper::raw_value(to), From::vclass, rounding_dir(dir)), dir); } template inline typename Enable_If::value && Is_Special::value, Result>::type construct(To& to, const From&, Rounding_Dir dir) { return check_result(Checked::construct_special ::Policy>(Native_Checked_To_Wrapper::raw_value(to), From::vclass, rounding_dir(dir)), dir); } template inline typename Enable_If::value, bool>::type is_minus_infinity(const T& x) { return Checked::is_minf ::Policy>(Native_Checked_From_Wrapper::raw_value(x)); } template inline typename Enable_If::value, bool>::type is_plus_infinity(const T& x) { return Checked::is_pinf ::Policy>(Native_Checked_From_Wrapper::raw_value(x)); } template inline typename Enable_If::value, int>::type is_infinity(const T& x) { return is_minus_infinity(x) ? -1 : is_plus_infinity(x) ? 1 : 0; } template inline typename Enable_If::value, bool>::type is_not_a_number(const T& x) { return Checked::is_nan ::Policy>(Native_Checked_From_Wrapper::raw_value(x)); } template inline typename Enable_If::value, bool>::type is_integer(const T& x) { return Checked::is_int ::Policy>(Native_Checked_From_Wrapper::raw_value(x)); } template inline Checked_Number::operator T() const { if (Policy::convertible) return v; } template inline T& Checked_Number::raw_value() { return v; } template inline const T& Checked_Number::raw_value() const { return v; } /*! \relates Checked_Number */ template inline const T& raw_value(const Checked_Number& x) { return x.raw_value(); } /*! \relates Checked_Number */ template inline T& raw_value(Checked_Number& x) { return x.raw_value(); } template inline bool Checked_Number::OK() const { return true; } template inline Result Checked_Number::classify(bool nan, bool inf, bool sign) const { return Checked::classify(v, nan, inf, sign); } template inline bool is_not_a_number(const Checked_Number& x) { return Checked::is_nan(x.raw_value()); } template inline bool is_minus_infinity(const Checked_Number& x) { return Checked::is_minf(x.raw_value()); } template inline bool is_plus_infinity(const Checked_Number& x) { return Checked::is_pinf(x.raw_value()); } /*! \relates Checked_Number */ template inline memory_size_type total_memory_in_bytes(const Checked_Number& x) { return total_memory_in_bytes(x.raw_value()); } /*! \relates Checked_Number */ template inline memory_size_type external_memory_in_bytes(const Checked_Number& x) { return external_memory_in_bytes(x.raw_value()); } /*! \relates Checked_Number */ template inline typename Enable_If::value, Result>::type assign_r(To& to, const char* x, Rounding_Dir dir) { std::istringstream s(x); return check_result(Checked::input ::Policy>(Native_Checked_To_Wrapper::raw_value(to), s, rounding_dir(dir)), dir); } #define PPL_DEFINE_FUNC1_A(name, func) \ template \ inline typename Enable_If::value \ && Is_Native_Or_Checked::value, \ Result>::type \ name(To& to, const From& x, Rounding_Dir dir) { \ return \ check_result(Checked::func \ ::Policy, \ typename Native_Checked_From_Wrapper \ ::Policy>(Native_Checked_To_Wrapper::raw_value(to), \ Native_Checked_From_Wrapper::raw_value(x), \ rounding_dir(dir)), dir); \ } PPL_DEFINE_FUNC1_A(construct, construct_ext) PPL_DEFINE_FUNC1_A(assign_r, assign_ext) PPL_DEFINE_FUNC1_A(floor_assign_r, floor_ext) PPL_DEFINE_FUNC1_A(ceil_assign_r, ceil_ext) PPL_DEFINE_FUNC1_A(trunc_assign_r, trunc_ext) PPL_DEFINE_FUNC1_A(neg_assign_r, neg_ext) PPL_DEFINE_FUNC1_A(abs_assign_r, abs_ext) PPL_DEFINE_FUNC1_A(sqrt_assign_r, sqrt_ext) #undef PPL_DEFINE_FUNC1_A #define PPL_DEFINE_FUNC1_B(name, func) \ template \ inline typename Enable_If::value \ && Is_Native_Or_Checked::value, \ Result>::type \ name(To& to, const From& x, int exp, Rounding_Dir dir) { \ return \ check_result(Checked::func \ ::Policy, \ typename Native_Checked_From_Wrapper \ ::Policy>(Native_Checked_To_Wrapper::raw_value(to), \ Native_Checked_From_Wrapper::raw_value(x), \ exp, \ rounding_dir(dir)), \ dir); \ } PPL_DEFINE_FUNC1_B(add_2exp_assign_r, add_2exp_ext) PPL_DEFINE_FUNC1_B(sub_2exp_assign_r, sub_2exp_ext) PPL_DEFINE_FUNC1_B(mul_2exp_assign_r, mul_2exp_ext) PPL_DEFINE_FUNC1_B(div_2exp_assign_r, div_2exp_ext) PPL_DEFINE_FUNC1_B(smod_2exp_assign_r, smod_2exp_ext) PPL_DEFINE_FUNC1_B(umod_2exp_assign_r, umod_2exp_ext) #undef PPL_DEFINE_FUNC1_B #define PPL_DEFINE_FUNC2(name, func) \ template \ inline typename Enable_If::value \ && Is_Native_Or_Checked::value \ && Is_Native_Or_Checked::value, \ Result>::type \ name(To& to, const From1& x, const From2& y, Rounding_Dir dir) { \ return \ check_result(Checked::func \ ::Policy, \ typename Native_Checked_From_Wrapper \ ::Policy, \ typename Native_Checked_From_Wrapper \ ::Policy>(Native_Checked_To_Wrapper::raw_value(to), \ Native_Checked_From_Wrapper::raw_value(x), \ Native_Checked_From_Wrapper::raw_value(y), \ rounding_dir(dir)), \ dir); \ } PPL_DEFINE_FUNC2(add_assign_r, add_ext) PPL_DEFINE_FUNC2(sub_assign_r, sub_ext) PPL_DEFINE_FUNC2(mul_assign_r, mul_ext) PPL_DEFINE_FUNC2(div_assign_r, div_ext) PPL_DEFINE_FUNC2(idiv_assign_r, idiv_ext) PPL_DEFINE_FUNC2(rem_assign_r, rem_ext) PPL_DEFINE_FUNC2(gcd_assign_r, gcd_ext) PPL_DEFINE_FUNC2(lcm_assign_r, lcm_ext) PPL_DEFINE_FUNC2(add_mul_assign_r, add_mul_ext) PPL_DEFINE_FUNC2(sub_mul_assign_r, sub_mul_ext) #undef PPL_DEFINE_FUNC2 #define PPL_DEFINE_FUNC4(name, func) \ template \ inline typename Enable_If::value \ && Is_Native_Or_Checked::value \ && Is_Native_Or_Checked::value \ && Is_Native_Or_Checked::value \ && Is_Native_Or_Checked::value, \ Result>::type \ name(To1& to, To2& s, To3& t, const From1& x, const From2& y, \ Rounding_Dir dir) { \ return \ check_result \ (Checked::func::Policy, \ typename Native_Checked_To_Wrapper::Policy, \ typename Native_Checked_To_Wrapper::Policy, \ typename Native_Checked_From_Wrapper::Policy, \ typename Native_Checked_From_Wrapper::Policy> \ (Native_Checked_To_Wrapper::raw_value(to), \ Native_Checked_To_Wrapper::raw_value(s), \ Native_Checked_To_Wrapper::raw_value(t), \ Native_Checked_From_Wrapper::raw_value(x), \ Native_Checked_From_Wrapper::raw_value(y), \ rounding_dir(dir)), \ dir); \ } PPL_DEFINE_FUNC4(gcdext_assign_r, gcdext_ext) #undef PPL_DEFINE_PPL_DEFINE_FUNC4 #define PPL_DEFINE_INCREMENT(f, fun) \ template \ inline Checked_Number& \ Checked_Number::f() { \ Policy::handle_result(fun(*this, *this, T(1), \ Policy::ROUND_DEFAULT_OPERATOR)); \ return *this; \ } \ template \ inline Checked_Number \ Checked_Number::f(int) {\ T r = v;\ Policy::handle_result(fun(*this, *this, T(1), \ Policy::ROUND_DEFAULT_OPERATOR)); \ return r;\ } PPL_DEFINE_INCREMENT(operator ++, add_assign_r) PPL_DEFINE_INCREMENT(operator --, sub_assign_r) #undef PPL_DEFINE_INCREMENT template inline Checked_Number& Checked_Number::operator=(const Checked_Number& y) { Checked::copy(v, y.raw_value()); return *this; } template template inline Checked_Number& Checked_Number::operator=(const From& y) { Policy::handle_result(assign_r(*this, y, Policy::ROUND_DEFAULT_OPERATOR)); return *this; } #define PPL_DEFINE_BINARY_OP_ASSIGN(f, fun) \ template \ template \ inline Checked_Number& \ Checked_Number::f(const Checked_Number& y) { \ Policy::handle_result(fun(*this, *this, y, \ Policy::ROUND_DEFAULT_OPERATOR)); \ return *this; \ } \ template \ inline Checked_Number& \ Checked_Number::f(const T& y) { \ Policy::handle_result(fun(*this, *this, y, \ Policy::ROUND_DEFAULT_OPERATOR)); \ return *this; \ } \ template \ template \ inline typename Enable_If::value, \ Checked_Number& >::type \ Checked_Number::f(const From& y) { \ Checked_Number cy(y); \ Policy::handle_result(fun(*this, *this, cy, \ Policy::ROUND_DEFAULT_OPERATOR)); \ return *this; \ } PPL_DEFINE_BINARY_OP_ASSIGN(operator +=, add_assign_r) PPL_DEFINE_BINARY_OP_ASSIGN(operator -=, sub_assign_r) PPL_DEFINE_BINARY_OP_ASSIGN(operator *=, mul_assign_r) PPL_DEFINE_BINARY_OP_ASSIGN(operator /=, div_assign_r) PPL_DEFINE_BINARY_OP_ASSIGN(operator %=, rem_assign_r) #undef PPL_DEFINE_BINARY_OP_ASSIGN #define PPL_DEFINE_BINARY_OP(f, fun) \ template \ inline Checked_Number \ f(const Checked_Number& x, const Checked_Number& y) { \ Checked_Number r; \ Policy::handle_result(fun(r, x, y, Policy::ROUND_DEFAULT_OPERATOR)); \ return r; \ } \ template \ inline \ typename Enable_If::value, Checked_Number >::type \ f(const Type& x, const Checked_Number& y) { \ Checked_Number r(x); \ Policy::handle_result(fun(r, r, y, Policy::ROUND_DEFAULT_OPERATOR)); \ return r; \ } \ template \ inline \ typename Enable_If::value, Checked_Number >::type \ f(const Checked_Number& x, const Type& y) { \ Checked_Number r(y); \ Policy::handle_result(fun(r, x, r, Policy::ROUND_DEFAULT_OPERATOR)); \ return r; \ } PPL_DEFINE_BINARY_OP(operator +, add_assign_r) PPL_DEFINE_BINARY_OP(operator -, sub_assign_r) PPL_DEFINE_BINARY_OP(operator *, mul_assign_r) PPL_DEFINE_BINARY_OP(operator /, div_assign_r) PPL_DEFINE_BINARY_OP(operator %, rem_assign_r) #undef PPL_DEFINE_BINARY_OP #define PPL_DEFINE_COMPARE_OP(f, fun) \ template \ inline \ typename Enable_If::value \ && Is_Native_Or_Checked::value \ && (Is_Checked::value || Is_Checked::value), \ bool>::type \ f(const T1& x, const T2& y) { \ return Checked::fun::Policy, \ typename Native_Checked_From_Wrapper::Policy> \ (Native_Checked_From_Wrapper::raw_value(x), \ Native_Checked_From_Wrapper::raw_value(y)); \ } PPL_DEFINE_COMPARE_OP(operator ==, eq_ext) PPL_DEFINE_COMPARE_OP(operator !=, ne_ext) PPL_DEFINE_COMPARE_OP(operator >=, ge_ext) PPL_DEFINE_COMPARE_OP(operator >, gt_ext) PPL_DEFINE_COMPARE_OP(operator <=, le_ext) PPL_DEFINE_COMPARE_OP(operator <, lt_ext) #undef PPL_DEFINE_COMPARE_OP #define PPL_DEFINE_COMPARE(f, fun) \ template \ inline typename Enable_If::value \ && Is_Native_Or_Checked::value, \ bool>::type \ f(const T1& x, const T2& y) { \ return Checked::fun::Policy, \ typename Native_Checked_From_Wrapper::Policy> \ (Native_Checked_From_Wrapper::raw_value(x), \ Native_Checked_From_Wrapper::raw_value(y)); \ } PPL_DEFINE_COMPARE(equal, eq_ext) PPL_DEFINE_COMPARE(not_equal, ne_ext) PPL_DEFINE_COMPARE(greater_or_equal, ge_ext) PPL_DEFINE_COMPARE(greater_than, gt_ext) PPL_DEFINE_COMPARE(less_or_equal, le_ext) PPL_DEFINE_COMPARE(less_than, lt_ext) #undef PPL_DEFINE_COMPARE /*! \relates Checked_Number */ template inline Checked_Number operator+(const Checked_Number& x) { return x; } /*! \relates Checked_Number */ template inline Checked_Number operator-(const Checked_Number& x) { Checked_Number r; Policy::handle_result(neg_assign_r(r, x, Policy::ROUND_DEFAULT_OPERATOR)); return r; } #define PPL_DEFINE_ASSIGN_FUN2_1(f, fun) \ template \ inline void \ f(Checked_Number& x) { \ Policy::handle_result(fun(x, x, Policy::ROUND_DEFAULT_FUNCTION)); \ } #define PPL_DEFINE_ASSIGN_FUN2_2(f, fun) \ template \ inline void \ f(Checked_Number& x, const Checked_Number& y) { \ Policy::handle_result(fun(x, y, Policy::ROUND_DEFAULT_FUNCTION)); \ } #define PPL_DEFINE_ASSIGN_FUN3_3(f, fun) \ template \ inline void \ f(Checked_Number& x, const Checked_Number& y, \ const Checked_Number& z) { \ Policy::handle_result(fun(x, y, z, Policy::ROUND_DEFAULT_FUNCTION)); \ } #define PPL_DEFINE_ASSIGN_FUN5_5(f, fun) \ template \ inline void \ f(Checked_Number& x, \ Checked_Number& s, Checked_Number& t, \ const Checked_Number& y, \ const Checked_Number& z) { \ Policy::handle_result(fun(x, s, t, y, z, Policy::ROUND_DEFAULT_FUNCTION)); \ } PPL_DEFINE_ASSIGN_FUN2_2(sqrt_assign, sqrt_assign_r) PPL_DEFINE_ASSIGN_FUN2_1(floor_assign, floor_assign_r) PPL_DEFINE_ASSIGN_FUN2_2(floor_assign, floor_assign_r) PPL_DEFINE_ASSIGN_FUN2_1(ceil_assign, ceil_assign_r) PPL_DEFINE_ASSIGN_FUN2_2(ceil_assign, ceil_assign_r) PPL_DEFINE_ASSIGN_FUN2_1(trunc_assign, trunc_assign_r) PPL_DEFINE_ASSIGN_FUN2_2(trunc_assign, trunc_assign_r) PPL_DEFINE_ASSIGN_FUN2_1(neg_assign, neg_assign_r) PPL_DEFINE_ASSIGN_FUN2_2(neg_assign, neg_assign_r) PPL_DEFINE_ASSIGN_FUN2_1(abs_assign, abs_assign_r) PPL_DEFINE_ASSIGN_FUN2_2(abs_assign, abs_assign_r) PPL_DEFINE_ASSIGN_FUN3_3(add_mul_assign, add_mul_assign_r) PPL_DEFINE_ASSIGN_FUN3_3(sub_mul_assign, sub_mul_assign_r) PPL_DEFINE_ASSIGN_FUN3_3(rem_assign, rem_assign_r) PPL_DEFINE_ASSIGN_FUN3_3(gcd_assign, gcd_assign_r) PPL_DEFINE_ASSIGN_FUN5_5(gcdext_assign, gcdext_assign_r) PPL_DEFINE_ASSIGN_FUN3_3(lcm_assign, lcm_assign_r) #undef PPL_DEFINE_ASSIGN_FUN2_1 #undef PPL_DEFINE_ASSIGN_FUN2_2 #undef PPL_DEFINE_ASSIGN_FUN3_2 #undef PPL_DEFINE_ASSIGN_FUN3_3 #undef PPL_DEFINE_ASSIGN_FUN5_5 #define PPL_DEFINE_ASSIGN_2EXP(f, fun) \ template \ inline void \ f(Checked_Number& to, \ const Checked_Number& x, unsigned int exp) { \ Policy::handle_result(fun(to, x, exp, Policy::ROUND_DEFAULT_FUNCTION)); \ } PPL_DEFINE_ASSIGN_2EXP(mul_2exp_assign, mul_2exp_assign_r) PPL_DEFINE_ASSIGN_2EXP(div_2exp_assign, div_2exp_assign_r) template inline void exact_div_assign(Checked_Number& x, const Checked_Number& y, const Checked_Number& z) { Policy::handle_result(div_assign_r(x, y, z, ROUND_NOT_NEEDED)); } /*! \relates Checked_Number */ template inline typename Enable_If::value, int>::type sgn(const From& x) { Result_Relation r = Checked::sgn_ext::Policy>(Native_Checked_From_Wrapper::raw_value(x)); switch (r) { case VR_LT: return -1; case VR_EQ: return 0; case VR_GT: return 1; default: throw(0); } } /*! \relates Checked_Number */ template inline typename Enable_If::value && Is_Native_Or_Checked::value, int>::type cmp(const From1& x, const From2& y) { Result_Relation r = Checked::cmp_ext::Policy, typename Native_Checked_From_Wrapper::Policy> (Native_Checked_From_Wrapper::raw_value(x), Native_Checked_From_Wrapper::raw_value(y)); switch (r) { case VR_LT: return -1; case VR_EQ: return 0; case VR_GT: return 1; default: throw(0); } } /*! \relates Checked_Number */ template typename Enable_If::value, Result>::type output(std::ostream& os, const T& x, const Numeric_Format& fmt, Rounding_Dir dir) { return check_result(Checked::output_ext::Policy> (os, Native_Checked_From_Wrapper::raw_value(x), fmt, rounding_dir(dir)), dir); } /*! \relates Checked_Number */ template inline std::ostream& operator<<(std::ostream& os, const Checked_Number& x) { Policy::handle_result(output(os, x, Numeric_Format(), ROUND_IGNORE)); return os; } /*! \relates Checked_Number */ template typename Enable_If::value, Result>::type input(T& x, std::istream& is, Rounding_Dir dir) { return check_result(Checked::input_ext::Policy> (Native_Checked_To_Wrapper::raw_value(x), is, rounding_dir(dir)), dir); } /*! \relates Checked_Number */ template inline std::istream& operator>>(std::istream& is, Checked_Number& x) { Result r = input(x, is, Policy::ROUND_DEFAULT_INPUT); if (r == V_CVT_STR_UNK) is.setstate(std::ios::failbit); else Policy::handle_result(r); return is; } template inline T plus_infinity() { return PLUS_INFINITY; } template inline T minus_infinity() { return MINUS_INFINITY; } template inline T not_a_number() { return NOT_A_NUMBER; } /*! \relates Checked_Number */ template inline void swap(Checked_Number& x, Checked_Number& y) { using std::swap; swap(x.raw_value(), y.raw_value()); } template inline void maybe_reset_fpu_inexact() { if (FPU_Related::value) return fpu_reset_inexact(); } template inline int maybe_check_fpu_inexact() { if (FPU_Related::value) return fpu_check_inexact(); else return 0; } } // namespace Parma_Polyhedra_Library #endif // !defined(PPL_Checked_Number_inlines_hh)