...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::date_time::int_adapter — Adapter to create integer types with +-infinity, and not a value.
// In header: <boost/date_time/int_adapter.hpp> template<typename int_type_> class int_adapter { public: // types typedef int_type_ int_type; // construct/copy/destruct int_adapter(int_type); // public member functions bool is_infinity() const; bool is_pos_infinity() const; bool is_neg_infinity() const; bool is_nan() const; bool is_special() const; bool operator==(const int_adapter &) const; bool operator==(const int &) const; bool operator!=(const int_adapter &) const; bool operator!=(const int &) const; bool operator<(const int_adapter &) const; bool operator<(const int &) const; bool operator>(const int_adapter &) const; int_type as_number() const; special_values as_special() const; template<typename rhs_type> int_adapter operator+(const int_adapter< rhs_type > &) const; int_adapter operator+(const int_type) const; template<typename rhs_type> int_adapter operator-(const int_adapter< rhs_type > &) const; int_adapter operator-(const int_type) const; int_adapter operator*(const int_adapter &) const; int_adapter operator*(const int) const; int_adapter operator/(const int_adapter &) const; int_adapter operator/(const int) const; int_adapter operator%(const int_adapter &) const; int_adapter operator%(const int) const; // public static functions static bool has_infinity() ; static const int_adapter pos_infinity() ; static const int_adapter neg_infinity() ; static const int_adapter not_a_number() ; static int_adapter max BOOST_PREVENT_MACRO_SUBSTITUTION() ; static int_adapter min BOOST_PREVENT_MACRO_SUBSTITUTION() ; static int_adapter from_special(special_values) ; static bool is_inf(int_type) ; static bool is_neg_inf(int_type) ; static bool is_pos_inf(int_type) ; static bool is_not_a_number(int_type) ; static special_values to_special(int_type) ; static int_type maxcount() ; // private member functions int compare(const int_adapter &) const; int_adapter mult_div_specials(const int_adapter &) const; int_adapter mult_div_specials(const int &) const; };
This class is used internally in counted date/time representations. It adds the floating point like features of infinities and not a number. It also provides mathmatical operations with consideration to special values following these rules:
+infinity - infinity == Not A Number (NAN) infinity * non-zero == infinity infinity * zero == NAN +infinity * -integer == -infinity infinity / infinity == NAN infinity * infinity == infinity *
int_adapter
public member functionsbool is_infinity() const;
bool is_pos_infinity() const;
bool is_neg_infinity() const;
bool is_nan() const;
bool is_special() const;
bool operator==(const int_adapter & rhs) const;
bool operator==(const int & rhs) const;
bool operator!=(const int_adapter & rhs) const;
bool operator!=(const int & rhs) const;
bool operator<(const int_adapter & rhs) const;
bool operator<(const int & rhs) const;
bool operator>(const int_adapter & rhs) const;
int_type as_number() const;
special_values as_special() const;Returns either special value type or is_not_special.
template<typename rhs_type> int_adapter operator+(const int_adapter< rhs_type > & rhs) const;
Operator allows for adding dissimilar int_adapter types. The return type will match that of the the calling object's type
int_adapter operator+(const int_type rhs) const;
template<typename rhs_type> int_adapter operator-(const int_adapter< rhs_type > & rhs) const;
Operator allows for subtracting dissimilar int_adapter types. The return type will match that of the the calling object's type
int_adapter operator-(const int_type rhs) const;
int_adapter operator*(const int_adapter & rhs) const;
int_adapter operator*(const int rhs) const;
Provided for cases when automatic conversion from 'int' to 'int_adapter' causes incorrect results.
int_adapter operator/(const int_adapter & rhs) const;
int_adapter operator/(const int rhs) const;
Provided for cases when automatic conversion from 'int' to 'int_adapter' causes incorrect results.
int_adapter operator%(const int_adapter & rhs) const;
int_adapter operator%(const int rhs) const;
Provided for cases when automatic conversion from 'int' to 'int_adapter' causes incorrect results.
int_adapter
public static functionsstatic bool has_infinity() ;
static const int_adapter pos_infinity() ;
static const int_adapter neg_infinity() ;
static const int_adapter not_a_number() ;
static int_adapter max BOOST_PREVENT_MACRO_SUBSTITUTION() ;
static int_adapter min BOOST_PREVENT_MACRO_SUBSTITUTION() ;
static int_adapter from_special(special_values sv) ;
static bool is_inf(int_type v) ;
static bool is_neg_inf(int_type v) ;
static bool is_pos_inf(int_type v) ;
static bool is_not_a_number(int_type v) ;
static special_values to_special(int_type v) ;Returns either special value type or is_not_special.
static int_type maxcount() ;
int_adapter
private member functionsint compare(const int_adapter & rhs) const;returns -1, 0, 1, or 2 if 'this' is <, ==, >, or 'nan comparison' rhs
int_adapter mult_div_specials(const int_adapter & rhs) const;Assumes at least 'this' or 'rhs' is a special value.
int_adapter mult_div_specials(const int & rhs) const;Assumes 'this' is a special value.