Boost C++ Libraries

...one 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.
PrevUpHomeNext

Struct template pointer_traits

boost::intrusive::pointer_traits

Synopsis

// In header: <boost/intrusive/pointer_traits.hpp>

template<typename Ptr> 
struct pointer_traits {
  // types
  typedef Ptr              pointer;        
  typedef unspecified_type element_type;   
  typedef unspecified_type difference_type;
  typedef element_type &   reference;      

  // public static functions
  static pointer pointer_to(reference);
  template<typename UPtr> static pointer static_cast_from(const UPtr &);
  template<typename UPtr> static pointer const_cast_from(const UPtr &);
  template<typename UPtr> static pointer dynamic_cast_from(const UPtr &);
};

Description

pointer_traits is the implementation of C++11 std::pointer_traits class with some extensions like castings.

pointer_traits supplies a uniform interface to certain attributes of pointer-like types.

pointer_traits public types

  1. typedef Ptr pointer;

    The pointer type queried by this pointer_traits instantiation

  2. typedef unspecified_type element_type;

    Ptr::element_type if such a type exists; otherwise, T if Ptr is a class template instantiation of the form SomePointer<T, Args>, where Args is zero or more type arguments ; otherwise , the specialization is ill-formed.

  3. typedef unspecified_type difference_type;

    Ptr::difference_type if such a type exists; otherwise, std::ptrdiff_t.

  4. typedef element_type & reference;

    Ptr::rebind<U> if such a type exists; otherwise, SomePointer<U, Args> if Ptr is a class template instantiation of the form SomePointer<T, Args>, where Args is zero or more type arguments ; otherwise, the instantiation of rebind is ill-formed.

pointer_traits public static functions

  1. static pointer pointer_to(reference r);

    Remark: If element_type is (possibly cv-qualified) void, r type is unspecified; otherwise, it is element_type &.

    Returns: A dereferenceable pointer to r obtained by calling Ptr::pointer_to(r). Non-standard extension: If such function does not exist, returns pointer(addressof(r));

  2. template<typename UPtr> static pointer static_cast_from(const UPtr & uptr);

    Remark: Non-standard extension.

    Returns: A dereferenceable pointer to r obtained by calling Ptr::static_cast_from(r). If such function does not exist, returns pointer_to(static_cast<element_type&>(*uptr))

  3. template<typename UPtr> static pointer const_cast_from(const UPtr & uptr);

    Remark: Non-standard extension.

    Returns: A dereferenceable pointer to r obtained by calling Ptr::const_cast_from(r). If such function does not exist, returns pointer_to(const_cast<element_type&>(*uptr))

  4. template<typename UPtr> static pointer dynamic_cast_from(const UPtr & uptr);

    Remark: Non-standard extension.

    Returns: A dereferenceable pointer to r obtained by calling Ptr::dynamic_cast_from(r). If such function does not exist, returns pointer_to(*dynamic_cast<element_type*>(&*uptr))


PrevUpHomeNext