PPL
1.1pre8
|
A wrapper for numeric types implementing a given policy. More...
#include <ppl.hh>
Public Member Functions | |
bool | OK () const |
Checks if all the invariants are satisfied. | |
Result | classify (bool nan=true, bool inf=true, bool sign=true) const |
Classifies *this. | |
Constructors | |
Checked_Number () | |
Default constructor. | |
Checked_Number (const Checked_Number &y) | |
Copy constructor. | |
template<typename From , typename From_Policy > | |
Checked_Number (const Checked_Number< From, From_Policy > &y, Rounding_Dir dir) | |
Direct initialization from a Checked_Number and rounding mode. | |
Checked_Number (char y, Rounding_Dir dir) | |
Direct initialization from a plain char and rounding mode. | |
Checked_Number (signed char y, Rounding_Dir dir) | |
Direct initialization from a signed char and rounding mode. | |
Checked_Number (signed short y, Rounding_Dir dir) | |
Direct initialization from a signed short and rounding mode. | |
Checked_Number (signed int y, Rounding_Dir dir) | |
Direct initialization from a signed int and rounding mode. | |
Checked_Number (signed long y, Rounding_Dir dir) | |
Direct initialization from a signed long and rounding mode. | |
Checked_Number (signed long long y, Rounding_Dir dir) | |
Direct initialization from a signed long long and rounding mode. | |
Checked_Number (unsigned char y, Rounding_Dir dir) | |
Direct initialization from an unsigned char and rounding mode. | |
Checked_Number (unsigned short y, Rounding_Dir dir) | |
Direct initialization from an unsigned short and rounding mode. | |
Checked_Number (unsigned int y, Rounding_Dir dir) | |
Direct initialization from an unsigned int and rounding mode. | |
Checked_Number (unsigned long y, Rounding_Dir dir) | |
Direct initialization from an unsigned long and rounding mode. | |
Checked_Number (unsigned long long y, Rounding_Dir dir) | |
Direct initialization from an unsigned long long and rounding mode. | |
Checked_Number (float y, Rounding_Dir dir) | |
Direct initialization from a float and rounding mode. | |
Checked_Number (double y, Rounding_Dir dir) | |
Direct initialization from a double and rounding mode. | |
Checked_Number (long double y, Rounding_Dir dir) | |
Direct initialization from a long double and rounding mode. | |
Checked_Number (const mpq_class &y, Rounding_Dir dir) | |
Direct initialization from a rational and rounding mode. | |
Checked_Number (const mpz_class &y, Rounding_Dir dir) | |
Direct initialization from an unbounded integer and rounding mode. | |
Checked_Number (const char *y, Rounding_Dir dir) | |
Direct initialization from a C string and rounding mode. | |
template<typename From > | |
Checked_Number (const From &, Rounding_Dir dir, typename Enable_If< Is_Special< From >::value, bool >::type ignored=false) | |
Direct initialization from special and rounding mode. | |
template<typename From , typename From_Policy > | |
Checked_Number (const Checked_Number< From, From_Policy > &y) | |
Direct initialization from a Checked_Number, default rounding mode. | |
Checked_Number (char y) | |
Direct initialization from a plain char, default rounding mode. | |
Checked_Number (signed char y) | |
Direct initialization from a signed char, default rounding mode. | |
Checked_Number (signed short y) | |
Direct initialization from a signed short, default rounding mode. | |
Checked_Number (signed int y) | |
Direct initialization from a signed int, default rounding mode. | |
Checked_Number (signed long y) | |
Direct initialization from a signed long, default rounding mode. | |
Checked_Number (signed long long y) | |
Direct initialization from a signed long long, default rounding mode. | |
Checked_Number (unsigned char y) | |
Direct initialization from an unsigned char, default rounding mode. | |
Checked_Number (unsigned short y) | |
Direct initialization from an unsigned short, default rounding mode. | |
Checked_Number (unsigned int y) | |
Direct initialization from an unsigned int, default rounding mode. | |
Checked_Number (unsigned long y) | |
Direct initialization from an unsigned long, default rounding mode. | |
Checked_Number (unsigned long long y) | |
Direct initialization from an unsigned long long, default rounding mode. | |
Checked_Number (float y) | |
Direct initialization from a float, default rounding mode. | |
Checked_Number (double y) | |
Direct initialization from a double, default rounding mode. | |
Checked_Number (long double y) | |
Direct initialization from a long double, default rounding mode. | |
Checked_Number (const mpq_class &y) | |
Direct initialization from a rational, default rounding mode. | |
Checked_Number (const mpz_class &y) | |
Direct initialization from an unbounded integer, default rounding mode. | |
Checked_Number (const char *y) | |
Direct initialization from a C string, default rounding mode. | |
template<typename From > | |
Checked_Number (const From &, typename Enable_If< Is_Special< From >::value, bool >::type ignored=false) | |
Direct initialization from special, default rounding mode. | |
Accessors and Conversions | |
operator T () const | |
Conversion operator: returns a copy of the underlying numeric value. | |
T & | raw_value () |
Returns a reference to the underlying numeric value. | |
const T & | raw_value () const |
Returns a const reference to the underlying numeric value. | |
Assignment Operators | |
Checked_Number & | operator= (const Checked_Number &y) |
Assignment operator. | |
template<typename From > | |
Checked_Number & | operator= (const From &y) |
Assignment operator. | |
template<typename From_Policy > | |
Checked_Number & | operator+= (const Checked_Number< T, From_Policy > &y) |
Add and assign operator. | |
Checked_Number & | operator+= (const T &y) |
Add and assign operator. | |
template<typename From > | |
Enable_If < Is_Native_Or_Checked< From > ::value, Checked_Number< T, Policy > & >::type | operator+= (const From &y) |
Add and assign operator. | |
template<typename From_Policy > | |
Checked_Number & | operator-= (const Checked_Number< T, From_Policy > &y) |
Subtract and assign operator. | |
Checked_Number & | operator-= (const T &y) |
Subtract and assign operator. | |
template<typename From > | |
Enable_If < Is_Native_Or_Checked< From > ::value, Checked_Number< T, Policy > & >::type | operator-= (const From &y) |
Subtract and assign operator. | |
template<typename From_Policy > | |
Checked_Number & | operator*= (const Checked_Number< T, From_Policy > &y) |
Multiply and assign operator. | |
Checked_Number & | operator*= (const T &y) |
Multiply and assign operator. | |
template<typename From > | |
Enable_If < Is_Native_Or_Checked< From > ::value, Checked_Number< T, Policy > & >::type | operator*= (const From &y) |
Multiply and assign operator. | |
template<typename From_Policy > | |
Checked_Number & | operator/= (const Checked_Number< T, From_Policy > &y) |
Divide and assign operator. | |
Checked_Number & | operator/= (const T &y) |
Divide and assign operator. | |
template<typename From > | |
Enable_If < Is_Native_Or_Checked< From > ::value, Checked_Number< T, Policy > & >::type | operator/= (const From &y) |
Divide and assign operator. | |
template<typename From_Policy > | |
Checked_Number & | operator%= (const Checked_Number< T, From_Policy > &y) |
Compute remainder and assign operator. | |
Checked_Number & | operator%= (const T &y) |
Compute remainder and assign operator. | |
template<typename From > | |
Enable_If < Is_Native_Or_Checked< From > ::value, Checked_Number< T, Policy > & >::type | operator%= (const From &y) |
Compute remainder and assign operator. | |
Increment and Decrement Operators | |
Checked_Number & | operator++ () |
Pre-increment operator. | |
Checked_Number | operator++ (int) |
Post-increment operator. | |
Checked_Number & | operator-- () |
Pre-decrement operator. | |
Checked_Number | operator-- (int) |
Post-decrement operator. | |
A wrapper for numeric types implementing a given policy.
The wrapper and related functions implement an interface which is common to all kinds of coefficient types, therefore allowing for a uniform coding style. This class also implements the policy encoded by the second template parameter. The default policy is to perform the detection of overflow errors.
|
inline |
Classifies *this.
Returns the appropriate Result characterizing:
*this
is NaN, if nan
is true
;*this
is a (positive or negative) infinity, if inf
is true
;*this
, if sign
is true
.