Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template offset_ptr

boost::interprocess::offset_ptr

Synopsis

// In header: <boost/interprocess/offset_ptr.hpp>

template<typename PointedType, typename DifferenceType, typename OffsetType, 
         std::size_t OffsetAlignment> 
class offset_ptr {
public:
  // types
  typedef PointedType                     element_type;     
  typedef PointedType *                   pointer;          
  typedef unspecified                     reference;        
  typedef unspecified                     value_type;       
  typedef DifferenceType                  difference_type;  
  typedef std::random_access_iterator_tag iterator_category;
  typedef OffsetType                      offset_type;      

  // member classes/structs/unions
  template<typename U> 
  struct rebind {
    // types
    typedef offset_ptr< U, DifferenceType, OffsetType, OffsetAlignment > other;
  };

  // construct/copy/destruct
  offset_ptr(pointer = 0);
  template<typename T> offset_ptr(T *, unspecified = 0);
  offset_ptr(const offset_ptr &);
  template<typename T2, typename P2, typename O2, std::size_t A2> 
    offset_ptr(const offset_ptr< T2, P2, O2, A2 > &, unspecified = 0);
  template<typename T2, typename P2, typename O2, std::size_t A2> 
    offset_ptr(const offset_ptr< T2, P2, O2, A2 > &, unspecified);
  template<typename T2, typename P2, typename O2, std::size_t A2> 
    offset_ptr(const offset_ptr< T2, P2, O2, A2 > &, unspecified);
  template<typename T2, typename P2, typename O2, std::size_t A2> 
    offset_ptr(const offset_ptr< T2, P2, O2, A2 > &, unspecified);
  template<typename T2, typename P2, typename O2, std::size_t A2> 
    offset_ptr(const offset_ptr< T2, P2, O2, A2 > &, unspecified);
  offset_ptr& operator=(pointer);
  offset_ptr& operator=(const offset_ptr &);
  template<typename T2, typename P2, typename O2, std::size_t A2> 
    offset_ptr& operator=(const offset_ptr< T2, P2, O2, A2 > &);

  // public member functions
  pointer get() const;
  offset_type get_offset() const;
  pointer operator->() const;
  reference operator*() const;
  template<typename T> reference operator[](T) const;
  offset_ptr & operator+=(difference_type);
  template<typename T> offset_ptr & operator-=(T);
  offset_ptr & operator++(void);
  offset_ptr operator++(int);
  offset_ptr & operator--(void);
  offset_ptr operator--(int);
  operator unspecified_bool_type() const;
  bool operator!() const;

  // public static functions
  static offset_ptr pointer_to(reference);

  // friend functions
  friend offset_ptr operator+(difference_type, const offset_ptr &);
  friend offset_ptr operator+(const offset_ptr &, difference_type);
  friend offset_ptr operator-(const offset_ptr &, difference_type);
  friend offset_ptr operator-(difference_type, const offset_ptr &);
  friend difference_type operator-(const offset_ptr &, const offset_ptr &);
};

Description

A smart pointer that stores the offset between between the pointer and the the object it points. This allows offset allows special properties, since the pointer is independent from the address address of the pointee, if the pointer and the pointee are still separated by the same offset. This feature converts offset_ptr in a smart pointer that can be placed in shared memory and memory mapped files mapped in different addresses in every process.

offset_ptr public construct/copy/destruct

  1. offset_ptr(pointer ptr = 0);

    Constructor from raw pointer (allows "0" pointer conversion). Never throws.

  2. template<typename T> offset_ptr(T * ptr, unspecified = 0);

    Constructor from other pointer. Never throws.

  3. offset_ptr(const offset_ptr & ptr);

    Constructor from other offset_ptr Never throws.

  4. template<typename T2, typename P2, typename O2, std::size_t A2> 
      offset_ptr(const offset_ptr< T2, P2, O2, A2 > & ptr, unspecified = 0);

    Constructor from other offset_ptr. If pointers of pointee types are convertible, offset_ptrs will be convertibles. Never throws.

  5. template<typename T2, typename P2, typename O2, std::size_t A2> 
      offset_ptr(const offset_ptr< T2, P2, O2, A2 > & r, unspecified);

    Emulates static_cast operator. Never throws.

  6. template<typename T2, typename P2, typename O2, std::size_t A2> 
      offset_ptr(const offset_ptr< T2, P2, O2, A2 > & r, unspecified);

    Emulates const_cast operator. Never throws.

  7. template<typename T2, typename P2, typename O2, std::size_t A2> 
      offset_ptr(const offset_ptr< T2, P2, O2, A2 > & r, unspecified);

    Emulates dynamic_cast operator. Never throws.

  8. template<typename T2, typename P2, typename O2, std::size_t A2> 
      offset_ptr(const offset_ptr< T2, P2, O2, A2 > & r, unspecified);

    Emulates reinterpret_cast operator. Never throws.

  9. offset_ptr& operator=(pointer from);

    Assignment from pointer (saves extra conversion). Never throws.

  10. offset_ptr& operator=(const offset_ptr & pt);

    Assignment from other offset_ptr. Never throws.

  11. template<typename T2, typename P2, typename O2, std::size_t A2> 
      offset_ptr& operator=(const offset_ptr< T2, P2, O2, A2 > & ptr);

    Assignment from related offset_ptr. If pointers of pointee types are assignable, offset_ptrs will be assignable. Never throws.

offset_ptr public member functions

  1. pointer get() const;

    Obtains raw pointer from offset. Never throws.

  2. offset_type get_offset() const;
  3. pointer operator->() const;

    Pointer-like -> operator. It can return 0 pointer. Never throws.

  4. reference operator*() const;

    Dereferencing operator, if it is a null offset_ptr behavior is undefined. Never throws.

  5. template<typename T> reference operator[](T idx) const;

    Indexing operator. Never throws.

  6. offset_ptr & operator+=(difference_type offset);

    offset_ptr += difference_type. Never throws.

  7. template<typename T> offset_ptr & operator-=(T offset);

    offset_ptr -= difference_type. Never throws.

  8. offset_ptr & operator++(void);

    ++offset_ptr. Never throws.

  9. offset_ptr operator++(int);

    offset_ptr++. Never throws.

  10. offset_ptr & operator--(void);

    --offset_ptr. Never throws.

  11. offset_ptr operator--(int);

    offset_ptr--. Never throws.

  12. operator unspecified_bool_type() const;

    safe bool conversion operator. Never throws.

  13. bool operator!() const;

    Not operator. Not needed in theory, but improves portability. Never throws

offset_ptr public static functions

  1. static offset_ptr pointer_to(reference r);

    Compatibility with pointer_traits

offset_ptr friend functions

  1. friend offset_ptr operator+(difference_type diff, const offset_ptr & right);

    difference_type + offset_ptr operation

  2. friend offset_ptr operator+(const offset_ptr & left, difference_type diff);

    offset_ptr + difference_type operation

  3. friend offset_ptr operator-(const offset_ptr & left, difference_type diff);

    offset_ptr - diff operation

  4. friend offset_ptr operator-(difference_type diff, const offset_ptr & right);

    offset_ptr - diff operation

  5. friend difference_type 
    operator-(const offset_ptr & pt, const offset_ptr & pt2);

    offset_ptr - offset_ptr operation


PrevUpHomeNext