class int_adapter {
public:
typedef int_type_ int_type;
- int_adapter(int_type v) :
+ BOOST_CXX14_CONSTEXPR int_adapter(int_type v) :
value_(v)
{}
- static bool has_infinity()
+ static BOOST_CONSTEXPR bool has_infinity()
{
return true;
}
- static const int_adapter pos_infinity()
+ static BOOST_CONSTEXPR int_adapter pos_infinity()
{
return (::std::numeric_limits<int_type>::max)();
}
- static const int_adapter neg_infinity()
+ static BOOST_CONSTEXPR int_adapter neg_infinity()
{
return (::std::numeric_limits<int_type>::min)();
}
- static const int_adapter not_a_number()
+ static BOOST_CONSTEXPR int_adapter not_a_number()
{
return (::std::numeric_limits<int_type>::max)()-1;
}
- static int_adapter max BOOST_PREVENT_MACRO_SUBSTITUTION ()
+ static BOOST_CONSTEXPR int_adapter max BOOST_PREVENT_MACRO_SUBSTITUTION ()
{
return (::std::numeric_limits<int_type>::max)()-2;
}
- static int_adapter min BOOST_PREVENT_MACRO_SUBSTITUTION ()
+ static BOOST_CONSTEXPR int_adapter min BOOST_PREVENT_MACRO_SUBSTITUTION ()
{
return (::std::numeric_limits<int_type>::min)()+1;
}
- static int_adapter from_special(special_values sv)
+ static BOOST_CXX14_CONSTEXPR int_adapter from_special(special_values sv)
{
switch (sv) {
case not_a_date_time: return not_a_number();
default: return not_a_number();
}
}
- static bool is_inf(int_type v)
+ static BOOST_CONSTEXPR bool is_inf(int_type v)
{
return (v == neg_infinity().as_number() ||
v == pos_infinity().as_number());
}
- static bool is_neg_inf(int_type v)
+ static BOOST_CXX14_CONSTEXPR bool is_neg_inf(int_type v)
{
return (v == neg_infinity().as_number());
}
- static bool is_pos_inf(int_type v)
+ static BOOST_CXX14_CONSTEXPR bool is_pos_inf(int_type v)
{
return (v == pos_infinity().as_number());
}
- static bool is_not_a_number(int_type v)
+ static BOOST_CXX14_CONSTEXPR bool is_not_a_number(int_type v)
{
return (v == not_a_number().as_number());
}
//! Returns either special value type or is_not_special
- static special_values to_special(int_type v)
+ static BOOST_CXX14_CONSTEXPR special_values to_special(int_type v)
{
if (is_not_a_number(v)) return not_a_date_time;
if (is_neg_inf(v)) return neg_infin;
}
//-3 leaves room for representations of infinity and not a date
- static int_type maxcount()
+ static BOOST_CONSTEXPR int_type maxcount()
{
return (::std::numeric_limits<int_type>::max)()-3;
}
- bool is_infinity() const
+ BOOST_CONSTEXPR bool is_infinity() const
{
return (value_ == neg_infinity().as_number() ||
value_ == pos_infinity().as_number());
}
- bool is_pos_infinity()const
+ BOOST_CONSTEXPR bool is_pos_infinity()const
{
return(value_ == pos_infinity().as_number());
}
- bool is_neg_infinity()const
+ BOOST_CONSTEXPR bool is_neg_infinity()const
{
return(value_ == neg_infinity().as_number());
}
- bool is_nan() const
+ BOOST_CONSTEXPR bool is_nan() const
{
return (value_ == not_a_number().as_number());
}
- bool is_special() const
+ BOOST_CONSTEXPR bool is_special() const
{
return(is_infinity() || is_nan());
}
- bool operator==(const int_adapter& rhs) const
+ BOOST_CONSTEXPR bool operator==(const int_adapter& rhs) const
{
return (compare(rhs) == 0);
}
- bool operator==(const int& rhs) const
+ BOOST_CXX14_CONSTEXPR bool operator==(const int& rhs) const
{
if(!std::numeric_limits<int_type>::is_signed)
{
}
return (compare(rhs) == 0);
}
- bool operator!=(const int_adapter& rhs) const
+ BOOST_CONSTEXPR bool operator!=(const int_adapter& rhs) const
{
return (compare(rhs) != 0);
}
- bool operator!=(const int& rhs) const
+ BOOST_CXX14_CONSTEXPR bool operator!=(const int& rhs) const
{
if(!std::numeric_limits<int_type>::is_signed)
{
}
return (compare(rhs) != 0);
}
- bool operator<(const int_adapter& rhs) const
+ BOOST_CONSTEXPR bool operator<(const int_adapter& rhs) const
{
return (compare(rhs) == -1);
}
- bool operator<(const int& rhs) const
+ BOOST_CXX14_CONSTEXPR bool operator<(const int& rhs) const
{
// quiets compiler warnings
if(!std::numeric_limits<int_type>::is_signed)
}
return (compare(rhs) == -1);
}
- bool operator>(const int_adapter& rhs) const
+ BOOST_CONSTEXPR bool operator>(const int_adapter& rhs) const
{
return (compare(rhs) == 1);
}
- int_type as_number() const
+ BOOST_CONSTEXPR int_type as_number() const
{
return value_;
}
//! Returns either special value type or is_not_special
- special_values as_special() const
+ BOOST_CONSTEXPR special_values as_special() const
{
return int_adapter::to_special(value_);
}
/*! Operator allows for adding dissimilar int_adapter types.
* The return type will match that of the the calling object's type */
template<class rhs_type>
- inline
+ BOOST_CXX14_CONSTEXPR
int_adapter operator+(const int_adapter<rhs_type>& rhs) const
{
if(is_special() || rhs.is_special())
return int_adapter<int_type>(value_ + static_cast<int_type>(rhs.as_number()));
}
+ BOOST_CXX14_CONSTEXPR
int_adapter operator+(const int_type rhs) const
{
if(is_special())
/*! Operator allows for subtracting dissimilar int_adapter types.
* The return type will match that of the the calling object's type */
template<class rhs_type>
- inline
+ BOOST_CXX14_CONSTEXPR
int_adapter operator-(const int_adapter<rhs_type>& rhs)const
{
if(is_special() || rhs.is_special())
}
return int_adapter<int_type>(value_ - static_cast<int_type>(rhs.as_number()));
}
+
+ BOOST_CXX14_CONSTEXPR
int_adapter operator-(const int_type rhs) const
{
if(is_special())
}
// should templatize this to be consistant with op +-
+ BOOST_CXX14_CONSTEXPR
int_adapter operator*(const int_adapter& rhs)const
{
if(this->is_special() || rhs.is_special())
}
return int_adapter<int_type>(value_ * rhs.value_);
}
+
/*! Provided for cases when automatic conversion from
* 'int' to 'int_adapter' causes incorrect results. */
+ BOOST_CXX14_CONSTEXPR
int_adapter operator*(const int rhs) const
{
if(is_special())
}
// should templatize this to be consistant with op +-
+ BOOST_CXX14_CONSTEXPR
int_adapter operator/(const int_adapter& rhs)const
{
if(this->is_special() || rhs.is_special())
return mult_div_specials(rhs);
}
else { // let divide by zero blow itself up
- return int_adapter<int_type>(value_ / rhs.value_);
+ return int_adapter<int_type>(value_ / rhs.value_); //NOLINT
}
}
return int_adapter<int_type>(value_ / rhs.value_);
}
+
/*! Provided for cases when automatic conversion from
* 'int' to 'int_adapter' causes incorrect results. */
+ BOOST_CXX14_CONSTEXPR
int_adapter operator/(const int rhs) const
{
if(is_special() && rhs != 0)
{
return mult_div_specials(rhs);
}
- return int_adapter<int_type>(value_ / rhs);
+ // let divide by zero blow itself up like int
+ return int_adapter<int_type>(value_ / rhs); //NOLINT
}
// should templatize this to be consistant with op +-
+ BOOST_CXX14_CONSTEXPR
int_adapter operator%(const int_adapter& rhs)const
{
if(this->is_special() || rhs.is_special())
return mult_div_specials(rhs);
}
else { // let divide by zero blow itself up
- return int_adapter<int_type>(value_ % rhs.value_);
+ return int_adapter<int_type>(value_ % rhs.value_); //NOLINT
}
}
return int_adapter<int_type>(value_ % rhs.value_);
}
+
/*! Provided for cases when automatic conversion from
* 'int' to 'int_adapter' causes incorrect results. */
+ BOOST_CXX14_CONSTEXPR
int_adapter operator%(const int rhs) const
{
if(is_special() && rhs != 0)
{
return mult_div_specials(rhs);
}
- return int_adapter<int_type>(value_ % rhs);
+ // let divide by zero blow itself up
+ return int_adapter<int_type>(value_ % rhs); //NOLINT
}
+
private:
int_type value_;
//! returns -1, 0, 1, or 2 if 'this' is <, ==, >, or 'nan comparison' rhs
- int compare(const int_adapter& rhs)const
+ BOOST_CXX14_CONSTEXPR
+ int compare( const int_adapter& rhs ) const
{
if(this->is_special() || rhs.is_special())
{
// implied-> if(value_ == rhs.value_)
return 0;
}
+
/* When multiplying and dividing with at least 1 special value
* very simmilar rules apply. In those cases where the rules
* are different, they are handled in the respective operator
* function. */
//! Assumes at least 'this' or 'rhs' is a special value
- int_adapter mult_div_specials(const int_adapter& rhs)const
+ BOOST_CXX14_CONSTEXPR
+ int_adapter mult_div_specials(const int_adapter& rhs) const
{
if(this->is_nan() || rhs.is_nan()) {
return int_adapter<int_type>(not_a_number());
//implied -> if(this->value_ == 0 || rhs.value_ == 0)
return int_adapter<int_type>(not_a_number());
}
+
/* Overloaded function necessary because of special
* situation where int_adapter is instantiated with
* 'unsigned' and func is called with negative int.
* It would produce incorrect results since 'unsigned'
* wraps around when initialized with a negative value */
//! Assumes 'this' is a special value
+ BOOST_CXX14_CONSTEXPR
int_adapter mult_div_specials(const int& rhs) const
{
if(this->is_nan()) {
//implied -> if(this->value_ == 0 || rhs.value_ == 0)
return int_adapter<int_type>(not_a_number());
}
-
+
};
#ifndef BOOST_DATE_TIME_NO_LOCALE