| Home | Libraries | People | FAQ | More

## Class template int_adapter

boost::date_time::int_adapter —

Adapter to create integer types with +-infinity, and not a value.

## Synopsis

    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
      bool has_infinity() ;
      const int_adapter pos_infinity() ;
      const int_adapter neg_infinity() ;
      const int_adapter not_a_number() ;
      int_adapter max BOOST_PREVENT_MACRO_SUBSTITUTION() ;
      int_adapter min BOOST_PREVENT_MACRO_SUBSTITUTION() ;
      int_adapter from_special(special_values) ;
      bool is_inf(int_type) ;
      bool is_neg_inf(int_type) ;
      bool is_pos_inf(int_type) ;
      bool is_not_a_number(int_type) ;
      special_values to_special(int_type) ;
      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;
    };

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

1.     int_adapter(int_type v);

### `int_adapter` public member functions

1.     bool is_infinity() const;

2.     bool is_pos_infinity() const;

3.     bool is_neg_infinity() const;

4.     bool is_nan() const;

5.     bool is_special() const;

6.     bool operator==(const int_adapter & rhs) const;

7.     bool operator==(const int & rhs) const;

8.     bool operator!=(const int_adapter & rhs) const;

9.     bool operator!=(const int & rhs) const;

10.     bool operator<(const int_adapter & rhs) const;

11.     bool operator<(const int & rhs) const;

12.     bool operator>(const int_adapter & rhs) const;

13.     int_type as_number() const;

14.     special_values as_special() const;

    Returns either special value type or is_not_special.

15.     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

16.     int_adapter operator+(const int_type rhs) const;

17.     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

18.     int_adapter operator-(const int_type rhs) const;

19.     int_adapter operator *(const int_adapter & rhs) const;

20.     int_adapter operator *(const int rhs) const;

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

21.     int_adapter operator/(const int_adapter & rhs) const;

22.     int_adapter operator/(const int rhs) const;

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

23.     int_adapter operator%(const int_adapter & rhs) const;

24.     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.     bool has_infinity() ;

2.     const int_adapter pos_infinity() ;

3.     const int_adapter neg_infinity() ;

4.     const int_adapter not_a_number() ;

5.     int_adapter max BOOST_PREVENT_MACRO_SUBSTITUTION() ;

6.     int_adapter min BOOST_PREVENT_MACRO_SUBSTITUTION() ;

7.     int_adapter from_special(special_values sv) ;

8.     bool is_inf(int_type v) ;

9.     bool is_neg_inf(int_type v) ;

10.     bool is_pos_inf(int_type v) ;

11.     bool is_not_a_number(int_type v) ;

12.     special_values to_special(int_type v) ;

    Returns either special value type or is_not_special.

13.     int_type maxcount() ;

### `int_adapter` private member functions

1.     int compare(const int_adapter & rhs) const;

   returns -1, 0, 1, or 2 if 'this' is <, ==, >, or 'nan comparison' rhs

2.     int_adapter mult_div_specials(const int_adapter & rhs) const;

   Assumes at least 'this' or 'rhs' is a special value.

3.     int_adapter mult_div_specials(const int & rhs) const;

   Assumes 'this' is a special value.

| Copyright © 2001-2004 CrystalClear Software, Inc