...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 BOOST_CONSTEXPR bool is_infinity() const; BOOST_CONSTEXPR bool is_pos_infinity() const; BOOST_CONSTEXPR bool is_neg_infinity() const; BOOST_CONSTEXPR bool is_nan() const; BOOST_CONSTEXPR bool is_special() const; BOOST_CONSTEXPR bool operator==(const int_adapter &) const; BOOST_CXX14_CONSTEXPR bool operator==(const int &) const; BOOST_CONSTEXPR bool operator!=(const int_adapter &) const; BOOST_CXX14_CONSTEXPR bool operator!=(const int &) const; BOOST_CONSTEXPR bool operator<(const int_adapter &) const; BOOST_CXX14_CONSTEXPR bool operator<(const int &) const; BOOST_CONSTEXPR bool operator>(const int_adapter &) const; BOOST_CONSTEXPR int_type as_number() const; BOOST_CONSTEXPR special_values as_special() const; template<typename rhs_type> BOOST_CXX14_CONSTEXPR int_adapter operator+(const int_adapter< rhs_type > &) const; BOOST_CXX14_CONSTEXPR int_adapter operator+(const int_type) const; template<typename rhs_type> BOOST_CXX14_CONSTEXPR int_adapter operator-(const int_adapter< rhs_type > &) const; BOOST_CXX14_CONSTEXPR int_adapter operator-(const int_type) const; BOOST_CXX14_CONSTEXPR int_adapter operator *(const int_adapter &) const; BOOST_CXX14_CONSTEXPR int_adapter operator *(const int) const; BOOST_CXX14_CONSTEXPR int_adapter operator/(const int_adapter &) const; BOOST_CXX14_CONSTEXPR int_adapter operator/(const int) const; BOOST_CXX14_CONSTEXPR int_adapter operator%(const int_adapter &) const; BOOST_CXX14_CONSTEXPR int_adapter operator%(const int) const; // public static functions static BOOST_CONSTEXPR bool has_infinity(); static BOOST_CONSTEXPR int_adapter pos_infinity(); static BOOST_CONSTEXPR int_adapter neg_infinity(); static BOOST_CONSTEXPR int_adapter not_a_number(); static BOOST_CONSTEXPR int_adapter max BOOST_PREVENT_MACRO_SUBSTITUTION(); static BOOST_CONSTEXPR int_adapter min BOOST_PREVENT_MACRO_SUBSTITUTION(); static BOOST_CXX14_CONSTEXPR int_adapter from_special(special_values); static BOOST_CONSTEXPR bool is_inf(int_type); static BOOST_CXX14_CONSTEXPR bool is_neg_inf(int_type); static BOOST_CXX14_CONSTEXPR bool is_pos_inf(int_type); static BOOST_CXX14_CONSTEXPR bool is_not_a_number(int_type); static BOOST_CXX14_CONSTEXPR special_values to_special(int_type); static BOOST_CONSTEXPR int_type maxcount(); // private member functions BOOST_CXX14_CONSTEXPR int compare(const int_adapter &) const; BOOST_CXX14_CONSTEXPR int_adapter mult_div_specials(const int_adapter &) const; BOOST_CXX14_CONSTEXPR 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 functionsBOOST_CONSTEXPR bool is_infinity() const;
BOOST_CONSTEXPR bool is_pos_infinity() const;
BOOST_CONSTEXPR bool is_neg_infinity() const;
BOOST_CONSTEXPR bool is_nan() const;
BOOST_CONSTEXPR bool is_special() const;
BOOST_CONSTEXPR bool operator==(const int_adapter & rhs) const;
BOOST_CXX14_CONSTEXPR bool operator==(const int & rhs) const;
BOOST_CONSTEXPR bool operator!=(const int_adapter & rhs) const;
BOOST_CXX14_CONSTEXPR bool operator!=(const int & rhs) const;
BOOST_CONSTEXPR bool operator<(const int_adapter & rhs) const;
BOOST_CXX14_CONSTEXPR bool operator<(const int & rhs) const;
BOOST_CONSTEXPR bool operator>(const int_adapter & rhs) const;
BOOST_CONSTEXPR int_type as_number() const;
BOOST_CONSTEXPR special_values as_special() const;Returns either special value type or is_not_special.
template<typename rhs_type> BOOST_CXX14_CONSTEXPR 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
BOOST_CXX14_CONSTEXPR int_adapter operator+(const int_type rhs) const;
template<typename rhs_type> BOOST_CXX14_CONSTEXPR 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
BOOST_CXX14_CONSTEXPR int_adapter operator-(const int_type rhs) const;
BOOST_CXX14_CONSTEXPR int_adapter operator *(const int_adapter & rhs) const;
BOOST_CXX14_CONSTEXPR int_adapter operator *(const int rhs) const;
Provided for cases when automatic conversion from 'int' to 'int_adapter
' causes incorrect results.
BOOST_CXX14_CONSTEXPR int_adapter operator/(const int_adapter & rhs) const;
BOOST_CXX14_CONSTEXPR int_adapter operator/(const int rhs) const;
Provided for cases when automatic conversion from 'int' to 'int_adapter
' causes incorrect results.
BOOST_CXX14_CONSTEXPR int_adapter operator%(const int_adapter & rhs) const;
BOOST_CXX14_CONSTEXPR 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 BOOST_CONSTEXPR bool has_infinity();
static BOOST_CONSTEXPR int_adapter pos_infinity();
static BOOST_CONSTEXPR int_adapter neg_infinity();
static BOOST_CONSTEXPR int_adapter not_a_number();
static BOOST_CONSTEXPR int_adapter max BOOST_PREVENT_MACRO_SUBSTITUTION();
static BOOST_CONSTEXPR int_adapter min BOOST_PREVENT_MACRO_SUBSTITUTION();
static BOOST_CXX14_CONSTEXPR int_adapter from_special(special_values sv);
static BOOST_CONSTEXPR bool is_inf(int_type v);
static BOOST_CXX14_CONSTEXPR bool is_neg_inf(int_type v);
static BOOST_CXX14_CONSTEXPR bool is_pos_inf(int_type v);
static BOOST_CXX14_CONSTEXPR bool is_not_a_number(int_type v);
static BOOST_CXX14_CONSTEXPR special_values to_special(int_type v);Returns either special value type or is_not_special.
static BOOST_CONSTEXPR int_type maxcount();
int_adapter
private member functionsBOOST_CXX14_CONSTEXPR int compare(const int_adapter & rhs) const;returns -1, 0, 1, or 2 if 'this' is <, ==, >, or 'nan comparison' rhs
BOOST_CXX14_CONSTEXPR int_adapter mult_div_specials(const int_adapter & rhs) const;Assumes at least 'this' or 'rhs' is a special value.
BOOST_CXX14_CONSTEXPR int_adapter mult_div_specials(const int & rhs) const;Assumes 'this' is a special value.