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

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Class template wrapping_int2

boost::date_time::wrapping_int2 — A wrapping integer used to wrap around at the top (WARNING: only instantiate with a signed type).


template<typename int_type_, int_type_ wrap_min, int_type_ wrap_max> 
class wrapping_int2 {
// types
typedef int_type_ int_type;

// construct/copy/destruct

// public member functions
int_type as_int() const;
operator int_type() const;
int_type add(int_type) ;
int_type subtract(int_type) ;

// public static functions
static int_type wrap_value() ;
static int_type min_value() ;

// private member functions
int_type calculate_wrap(int_type) ;


Bad name, quick impl to fix a bug -- fix later!! This allows the wrap to restart at a value other than 0.

wrapping_int2 construct/copy/destruct

  1. wrapping_int2(int_type v);

    If initializing value is out of range of [wrap_min, wrap_max], value will be initialized to closest of min or max

wrapping_int2 public member functions

  1. int_type as_int() const;
  2. operator int_type() const;
  3. int_type add(int_type v) ;

    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

  4. int_type subtract(int_type v) ;

    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

wrapping_int2 public static functions

  1. static int_type wrap_value() ;
  2. static int_type min_value() ;

wrapping_int2 private member functions

  1. int_type calculate_wrap(int_type wrap) ;
Copyright 2001-2005 CrystalClear Software, Inc