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

PrevUpHomeNext

Reference

Header <boost/move/algorithm.hpp>
Header <boost/move/core.hpp>
Header <boost/move/default_delete.hpp>
Header <boost/move/iterator.hpp>
Header <boost/move/make_unique.hpp>
Header <boost/move/move.hpp>
Header <boost/move/traits.hpp>
Header <boost/move/unique_ptr.hpp>
Header <boost/move/utility.hpp>
Header <boost/move/utility_core.hpp>
namespace boost {
  template<typename I, typename O> O move(I, I, O);
  template<typename I, typename O> O move_backward(I, I, O);
  template<typename I, typename F> F uninitialized_move(I, I, F);
  template<typename I, typename F> F uninitialized_copy_or_move(I, I, F);
  template<typename I, typename F> F copy_or_move(I, I, F);
}

This header implements macros to define movable classes and move-aware functions


BOOST_MOVE_IMPL_NO_COPY_CTOR_OR_ASSIGN(TYPE)
BOOST_MOVABLE_BUT_NOT_COPYABLE(TYPE)
BOOST_COPYABLE_AND_MOVABLE(TYPE)
BOOST_RV_REF(TYPE)
BOOST_RV_REF_BEG
BOOST_RV_REF_END
BOOST_COPY_ASSIGN_REF(TYPE)
BOOST_FWD_REF(TYPE)
BOOST_MOVE_RET(RET_TYPE, REF)
namespace boost {
  template<typename T> struct has_move_emulation_enabled;
}

Describes the default deleter (destruction policy) of unique_ptr: default_delete.

namespace boost {
  namespace move_upd {
    template<typename U, typename T> struct def_del_compatible_cond;
    template<typename U, typename T, typename Type = bmupmu::nat> 
      struct enable_def_del;
    template<typename U, typename T, typename Type = bmupmu::nat> 
      struct enable_defdel_call;
    struct bool_conversion;

    typedef int bool_conversion::* explicit_bool_arg;

    decltype(nullptr) typedef nullptr_type;
  }
  namespace movelib {
    template<typename T> struct default_delete;
  }
}
namespace boost {
  template<typename It> class move_iterator;
  template<typename C> class back_move_insert_iterator;
  template<typename C> class front_move_insert_iterator;
  template<typename C> class move_insert_iterator;
  template<typename It> move_iterator< It > make_move_iterator(const It &);
  template<typename C> back_move_insert_iterator< C > back_move_inserter(C &);
  template<typename C> 
    front_move_insert_iterator< C > front_move_inserter(C &);
  template<typename C> 
    move_insert_iterator< C > move_inserter(C &, typename C::iterator);
}

Defines "make_unique" functions, which are factories to create instances of unique_ptr depending on the passed arguments.

This header can be a bit heavyweight in C++03 compilers due to the use of the preprocessor library, that's why it's a a separate header from unique_ptr.hpp

namespace boost {
  namespace movelib {
    template<typename T, class... Args> 
      unique_ptr< T > make_unique(Args &&...);
    template<typename T, class... Args> 
      unique_ptr< T > make_unique_nothrow(Args &&...);
    template<typename T> unique_ptr< T > make_unique_definit();
    template<typename T> unique_ptr< T > make_unique_nothrow_definit();
    template<typename T> unique_ptr< T > make_unique(std::size_t);
    template<typename T> unique_ptr< T > make_unique_nothrow(std::size_t);
    template<typename T> unique_ptr< T > make_unique_definit(std::size_t);
    template<typename T> 
      unique_ptr< T > make_unique_nothrow_definit(std::size_t);
    template<typename T, class... Args> unspecified make_unique(Args &&);
    template<typename T, class... Args> 
      unspecified make_unique_definit(Args &&);
    template<typename T, class... Args> 
      unspecified make_unique_nothrow(Args &&);
    template<typename T, class... Args> 
      unspecified make_unique_nothrow_definit(Args &&);
  }
}

A general library header that includes the rest of top-level headers.

namespace boost {
  template<typename T> struct has_trivial_destructor_after_move;
  template<typename T> struct has_nothrow_move;
}

Describes the smart pointer unique_ptr, a drop-in replacement for std::unique_ptr, usable also from C++03 compilers.

Main differences from std::unique_ptr to avoid heavy dependencies, specially in C++03 compilers:

  • operator < uses pointer operator < instead of std::less<common_type>. This avoids dependencies on std::common_type and std::less (<type_traits>/<functional> headers. In C++03 this avoid pulling Boost.Typeof and other cascading dependencies. As in all Boost platforms operator < on raw pointers and other smart pointers provides strict weak ordering in practice this should not be a problem for users.

  • assignable from literal 0 for compilers without nullptr

  • unique_ptr<T[]> is constructible and assignable from unique_ptr<U[]> if cv-less T and cv-less U are the same type and T is more CV qualified than U.

namespace boost {
  namespace move_upd {
    template<typename D> struct deleter_types;
    template<typename P, typename D, 
             bool  = bmupmu::is_unary_function<D>::value || bmupmu::is_reference<D>::value> 
      struct unique_ptr_data;

    template<typename P, typename D> struct unique_ptr_data<P, D, false>;

    template<typename T> struct get_element_type;

    template<typename T> struct get_element_type<T *>;

    template<typename T> struct get_cvelement;
    template<typename P1, typename P2> struct is_same_cvelement_and_convertible;
    template<bool IsArray, typename FromPointer, typename ThisPointer> 
      struct is_unique_ptr_convertible;

    template<typename FromPointer, typename ThisPointer> 
      struct is_unique_ptr_convertible<false, FromPointer, ThisPointer>;

    template<typename T, typename FromPointer, typename ThisPointer, 
             typename Type = bmupmu::nat> 
      struct enable_up_ptr;
    template<typename T, typename D, typename U, typename E> 
      struct unique_moveconvert_assignable;
    template<typename T, typename D, typename U, typename E, 
             typename Type = bmupmu::nat> 
      struct enable_up_moveconv_assign;
    template<typename D, typename E, 
             bool IsReference = bmupmu::is_reference<D>::value> 
      struct unique_deleter_is_initializable;

    template<typename T, typename U> class is_rvalue_convertible;

    template<typename D, typename E> 
      struct unique_deleter_is_initializable<D, E, false>;

    template<typename T, typename D, typename U, typename E, 
             typename Type = bmupmu::nat> 
      struct enable_up_moveconv_constr;
  }
  namespace movelib {
    template<typename T, typename D = default_delete<T> > class unique_ptr;
    template<typename T, typename D> 
      void swap(unique_ptr< T, D > &, unique_ptr< T, D > &);
    template<typename T1, typename D1, typename T2, typename D2> 
      bool operator==(const unique_ptr< T1, D1 > &, 
                      const unique_ptr< T2, D2 > &);
    template<typename T1, typename D1, typename T2, typename D2> 
      bool operator!=(const unique_ptr< T1, D1 > &, 
                      const unique_ptr< T2, D2 > &);
    template<typename T1, typename D1, typename T2, typename D2> 
      bool operator<(const unique_ptr< T1, D1 > &, 
                     const unique_ptr< T2, D2 > &);
    template<typename T1, typename D1, typename T2, typename D2> 
      bool operator<=(const unique_ptr< T1, D1 > &, 
                      const unique_ptr< T2, D2 > &);
    template<typename T1, typename D1, typename T2, typename D2> 
      bool operator>(const unique_ptr< T1, D1 > &, 
                     const unique_ptr< T2, D2 > &);
    template<typename T1, typename D1, typename T2, typename D2> 
      bool operator>=(const unique_ptr< T1, D1 > &, 
                      const unique_ptr< T2, D2 > &);
    template<typename T, typename D> 
      bool operator==(const unique_ptr< T, D > &, std::nullptr_t);
    template<typename T, typename D> 
      bool operator==(std::nullptr_t, const unique_ptr< T, D > &);
    template<typename T, typename D> 
      bool operator!=(const unique_ptr< T, D > &, std::nullptr_t);
    template<typename T, typename D> 
      bool operator!=(std::nullptr_t, const unique_ptr< T, D > &);
    template<typename T, typename D> 
      bool operator<(const unique_ptr< T, D > &, std::nullptr_t);
    template<typename T, typename D> 
      bool operator<(std::nullptr_t, const unique_ptr< T, D > &);
    template<typename T, typename D> 
      bool operator>(const unique_ptr< T, D > &, std::nullptr_t);
    template<typename T, typename D> 
      bool operator>(std::nullptr_t, const unique_ptr< T, D > &);
    template<typename T, typename D> 
      bool operator<=(const unique_ptr< T, D > &, std::nullptr_t);
    template<typename T, typename D> 
      bool operator<=(std::nullptr_t, const unique_ptr< T, D > &);
    template<typename T, typename D> 
      bool operator>=(const unique_ptr< T, D > &, std::nullptr_t);
    template<typename T, typename D> 
      bool operator>=(std::nullptr_t, const unique_ptr< T, D > &);
  }
}

This header includes core utilities from <boost/move/utility_core.hpp> and defines some more advanced utilities such as:

namespace boost {
  template<typename T> 
    rvalue_reference_or_const_lvalue_reference 
    move_if_noexcept(input_reference);
}

This header defines core utilities to ease the development of move-aware functions. This header minimizes dependencies from other libraries.

namespace boost {
  template<typename T> struct enable_move_utility_emulation;
  template<typename T> rvalue_reference move(input_reference);
  template<typename T> output_reference forward(input_reference);
  template<typename T> 
    output_reference move_if_not_lvalue_reference(input_reference);
}

PrevUpHomeNext