...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::wrapping_int2 — A wrapping integer used to wrap around at the top (WARNING: only instantiate with a signed type)
// In header: <boost/date_time/wrapping_int.hpp> template<typename int_type_, int_type_ wrap_min, int_type_ wrap_max> class wrapping_int2 { public: // types typedef int_type_ int_type; // construct/copy/destruct wrapping_int2(int_type); // public static functions static BOOST_CONSTEXPR int_type wrap_value(); static BOOST_CONSTEXPR int_type min_value(); // public member functions BOOST_CONSTEXPR int_type as_int() const; BOOST_CONSTEXPR operator int_type() const; template<typename IntT> BOOST_CXX14_CONSTEXPR IntT add(IntT); template<typename IntT> BOOST_CXX14_CONSTEXPR IntT subtract(IntT); // private member functions template<typename IntT> BOOST_CXX14_CONSTEXPR IntT calculate_wrap(IntT); };
Bad name, quick impl to fix a bug – fix later!! This allows the wrap to restart at a value other than 0.
wrapping_int2
public member functionsBOOST_CONSTEXPR int_type as_int() const;Explicit converion method.
BOOST_CONSTEXPR operator int_type() const;
template<typename IntT> BOOST_CXX14_CONSTEXPR IntT add(IntT v);Add, return number of wraps performed.
The sign of the returned value will indicate which direction the wraps went. Ex: add a negative number and wrapping under could occur, this would be indicated by a negative return value. If wrapping over took place, a positive value would be returned
template<typename IntT> BOOST_CXX14_CONSTEXPR IntT subtract(IntT v);Subtract will return '-d' if wrapping under took place ('d' is the number of wraps)
The sign of the returned value will indicate which direction the wraps went. Ex: subtract a negative number and wrapping over could occur, this would be indicated by a positive return value. If wrapping under took place, a negative value would be returned