Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext

Class template int_adapter

boost::date_time::int_adapter — Adapter to create integer types with +-infinity, and not a value.

Synopsis

// 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;
};

Description

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 construct/copy/destruct

  1. int_adapter(int_type v);

int_adapter public member functions

  1. BOOST_CONSTEXPR bool is_infinity() const;
  2. BOOST_CONSTEXPR bool is_pos_infinity() const;
  3. BOOST_CONSTEXPR bool is_neg_infinity() const;
  4. BOOST_CONSTEXPR bool is_nan() const;
  5. BOOST_CONSTEXPR bool is_special() const;
  6. BOOST_CONSTEXPR bool operator==(const int_adapter & rhs) const;
  7. BOOST_CXX14_CONSTEXPR bool operator==(const int & rhs) const;
  8. BOOST_CONSTEXPR bool operator!=(const int_adapter & rhs) const;
  9. BOOST_CXX14_CONSTEXPR bool operator!=(const int & rhs) const;
  10. BOOST_CONSTEXPR bool operator<(const int_adapter & rhs) const;
  11. BOOST_CXX14_CONSTEXPR bool operator<(const int & rhs) const;
  12. BOOST_CONSTEXPR bool operator>(const int_adapter & rhs) const;
  13. BOOST_CONSTEXPR int_type as_number() const;
  14. BOOST_CONSTEXPR special_values as_special() const;
    Returns either special value type or is_not_special.
  15. 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

  16. BOOST_CXX14_CONSTEXPR int_adapter operator+(const int_type rhs) const;
  17. 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

  18. BOOST_CXX14_CONSTEXPR int_adapter operator-(const int_type rhs) const;
  19. BOOST_CXX14_CONSTEXPR int_adapter operator*(const int_adapter & rhs) const;
  20. BOOST_CXX14_CONSTEXPR int_adapter operator*(const int rhs) const;

    Provided for cases when automatic conversion from 'int' to 'int_adapter' causes incorrect results.

  21. BOOST_CXX14_CONSTEXPR int_adapter operator/(const int_adapter & rhs) const;
  22. BOOST_CXX14_CONSTEXPR int_adapter operator/(const int rhs) const;

    Provided for cases when automatic conversion from 'int' to 'int_adapter' causes incorrect results.

  23. BOOST_CXX14_CONSTEXPR int_adapter operator%(const int_adapter & rhs) const;
  24. 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 functions

  1. static BOOST_CONSTEXPR bool has_infinity();
  2. static BOOST_CONSTEXPR int_adapter pos_infinity();
  3. static BOOST_CONSTEXPR int_adapter neg_infinity();
  4. static BOOST_CONSTEXPR int_adapter not_a_number();
  5. static BOOST_CONSTEXPR int_adapter max BOOST_PREVENT_MACRO_SUBSTITUTION();
  6. static BOOST_CONSTEXPR int_adapter min BOOST_PREVENT_MACRO_SUBSTITUTION();
  7. static BOOST_CXX14_CONSTEXPR int_adapter from_special(special_values sv);
  8. static BOOST_CONSTEXPR bool is_inf(int_type v);
  9. static BOOST_CXX14_CONSTEXPR bool is_neg_inf(int_type v);
  10. static BOOST_CXX14_CONSTEXPR bool is_pos_inf(int_type v);
  11. static BOOST_CXX14_CONSTEXPR bool is_not_a_number(int_type v);
  12. static BOOST_CXX14_CONSTEXPR special_values to_special(int_type v);
    Returns either special value type or is_not_special.
  13. static BOOST_CONSTEXPR int_type maxcount();

int_adapter private member functions

  1. BOOST_CXX14_CONSTEXPR int compare(const int_adapter & rhs) const;
    returns -1, 0, 1, or 2 if 'this' is <, ==, >, or 'nan comparison' rhs
  2. BOOST_CXX14_CONSTEXPR int_adapter 
    mult_div_specials(const int_adapter & rhs) const;
    Assumes at least 'this' or 'rhs' is a special value.
  3. BOOST_CXX14_CONSTEXPR int_adapter mult_div_specials(const int & rhs) const;
    Assumes 'this' is a special value.

PrevUpHomeNext