</template><parametername="x"><paramtype>T &</paramtype></parameter><parametername="y"><paramtype>T &</paramtype></parameter><description><para>Exchanges the values of a and b, using Argument Dependent Lookup (ADL) to select a specialized swap function if available. If no specialized swap function is available, std::swap is used.</para><para><emphasisrole="bold">Exception</emphasis>: If T uses Boost.Move's move emulation and the compiler has no rvalue references then:</para><para><itemizedlist>
<listitem><para>If T has a <computeroutput>T::swap(T&)</computeroutput> member, that member is called.</para>
</listitem><listitem><para>Otherwise a move-based swap is called, equivalent to: <computeroutput>T t(::boost::move(x)); x = ::boost::move(y); y = ::boost::move(t);</computeroutput>. </para>
</template><parametername="first1"><paramtype>ForwardIt1</paramtype></parameter><parametername="last1"><paramtype>ForwardIt1</paramtype></parameter><parametername="first2"><paramtype>ForwardIt2</paramtype></parameter><description><para>Exchanges elements between range [first1, last1) and another range starting at first2 using boost::adl_move_swap.</para><para>Parameters: first1, last1 - the first range of elements to swap first2 - beginning of the second range of elements to swap</para><para>Type requirements:<itemizedlist>
</para><para>Return value: Iterator to the element past the last element exchanged in the range beginning with first2. </para></description></function>
</template><parametername="first"><paramtype>RandIt</paramtype></parameter><parametername="middle"><paramtype>RandIt</paramtype></parameter><parametername="last"><paramtype>RandIt</paramtype></parameter><parametername="comp"><paramtype>Compare</paramtype></parameter><parametername="uninitialized"><paramtype>typename iterator_traits< RandIt >::value_type *</paramtype><default>0</default></parameter><parametername="uninitialized_len"><paramtype>typename iterator_traits< RandIt >::size_type</paramtype><default>0</default></parameter><description><para><emphasisrole="bold">Effects</emphasis>: Merges two consecutive sorted ranges [first, middle) and [middle, last) into one sorted range [first, last) according to the given comparison function comp. The algorithm is stable (if there are equivalent elements in the original two ranges, the elements from the first range (preserving their original order) precede the elements from the second range (preserving their original order).</para><para><emphasisrole="bold">Requires</emphasis>:<itemizedlist>
<listitem><para>RandIt must meet the requirements of ValueSwappable and RandomAccessIterator.</para>
</listitem><listitem><para>The type of dereferenced RandIt must meet the requirements of MoveAssignable and MoveConstructible.</para>
<listitem><para>first: the beginning of the first sorted range.</para>
</listitem><listitem><para>middle: the end of the first sorted range and the beginning of the second</para>
</listitem><listitem><para>last: the end of the second sorted range</para>
</listitem><listitem><para>comp: comparison function object which returns true if the first argument is is ordered before the second.</para>
</listitem><listitem><para>uninitialized, uninitialized_len: raw storage starting on "uninitialized", able to hold "uninitialized_len" elements of type iterator_traits<RandIt>::value_type. Maximum performance is achieved when uninitialized_len is min(std::distance(first, middle), std::distance(middle, last)).</para>
</para><para><emphasisrole="bold">Throws</emphasis>: If comp throws or the move constructor, move assignment or swap of the type of dereferenced RandIt throws.</para><para><emphasisrole="bold">Complexity</emphasis>: Always K x O(N) comparisons and move assignments/constructors/swaps. Constant factor for comparisons and data movement is minimized when uninitialized_len is min(std::distance(first, middle), std::distance(middle, last)). Pretty good enough performance is achieved when uninitialized_len is ceil(sqrt(std::distance(first, last)))*2.</para><para><emphasisrole="bold">Caution</emphasis>: Experimental implementation, not production-ready. </para></description></function>
</template><parametername="first"><paramtype>RandIt</paramtype></parameter><parametername="last"><paramtype>RandIt</paramtype></parameter><parametername="comp"><paramtype>Compare</paramtype></parameter><parametername="uninitialized"><paramtype>RandRawIt</paramtype></parameter><parametername="uninitialized_len"><paramtype>typename iterator_traits< RandIt >::size_type</paramtype></parameter><description><para><emphasisrole="bold">Effects</emphasis>: Sorts the elements in the range [first, last) in ascending order according to comparison functor "comp". The sort is stable (order of equal elements is guaranteed to be preserved). Performance is improved if additional raw storage is provided.</para><para><emphasisrole="bold">Requires</emphasis>:<itemizedlist>
<listitem><para>RandIt must meet the requirements of ValueSwappable and RandomAccessIterator.</para>
</listitem><listitem><para>The type of dereferenced RandIt must meet the requirements of MoveAssignable and MoveConstructible.</para>
<listitem><para>first, last: the range of elements to sort</para>
</listitem><listitem><para>comp: comparison function object which returns true if the first argument is is ordered before the second.</para>
</listitem><listitem><para>uninitialized, uninitialized_len: raw storage starting on "uninitialized", able to hold "uninitialized_len" elements of type iterator_traits<RandIt>::value_type. Maximum performance is achieved when uninitialized_len is ceil(std::distance(first, last)/2).</para>
</para><para><emphasisrole="bold">Throws</emphasis>: If comp throws or the move constructor, move assignment or swap of the type of dereferenced RandIt throws.</para><para><emphasisrole="bold">Complexity</emphasis>: Always K x O(Nxlog(N)) comparisons and move assignments/constructors/swaps. Comparisons are close to minimum even with no additional memory. Constant factor for data movement is minimized when uninitialized_len is ceil(std::distance(first, last)/2). Pretty good enough performance is achieved when ceil(sqrt(std::distance(first, last)))*2.</para><para><emphasisrole="bold">Caution</emphasis>: Experimental implementation, not production-ready. </para></description></function>
</template><parametername="u"><paramtype>const U &</paramtype></parameter><parametername="v"><paramtype>const V &</paramtype></parameter></method>
</template><parametername="first"><paramtype>ForwardIterator</paramtype></parameter><parametername="last"><paramtype>ForwardIterator</paramtype></parameter><parametername="pred"><paramtype>BinaryPredicate</paramtype></parameter><description><para><emphasisrole="bold">Requires</emphasis>: The comparison function shall be an equivalence relation. The type of *first shall satisfy the MoveAssignable requirements</para><para><emphasisrole="bold">Effects</emphasis>: For a nonempty range, eliminates all but the first element from every consecutive group of equivalent elements referred to by the iterator i in the range [first + 1, last) for which the following conditions hold: pred(*(i - 1), *i) != false.</para><para><emphasisrole="bold">Returns</emphasis>: The end of the resulting range.</para><para><emphasisrole="bold">Complexity</emphasis>: For nonempty ranges, exactly (last - first) - 1 applications of the corresponding predicate. </para></description></function>
</programlisting></para><para><emphasisrole="bold">Returns</emphasis>: result</para><para><emphasisrole="bold">Note</emphasis>: This function is provided because <emphasis>std::uninitialized_copy</emphasis> from some STL implementations is not compatible with <emphasis><classnamealt="boost::move_iterator">move_iterator</classname></emphasis></para></description></function>
</template><parametername="f"><paramtype>I</paramtype></parameter><parametername="l"><paramtype>I</paramtype></parameter><parametername="r"><paramtype>F</paramtype></parameter><description><para><emphasisrole="bold">Effects</emphasis>: <programlistinglanguage="c++">for (; first != last; ++result, ++first)
*result = *first;
</programlisting></para><para><emphasisrole="bold">Returns</emphasis>: result</para><para><emphasisrole="bold">Note</emphasis>: This function is provided because <emphasis>std::uninitialized_copy</emphasis> from some STL implementations is not compatible with <emphasis><classnamealt="boost::move_iterator">move_iterator</classname></emphasis></para></description></function>
</template><description><para>This trait yields to a compile-time true boolean if T was marked as BOOST_MOVABLE_BUT_NOT_COPYABLE or BOOST_COPYABLE_AND_MOVABLE and rvalue references are not available on the platform. False otherwise. </para></description><data-membername="value"specifiers="static"><type>const bool</type></data-member>
<macroname="BOOST_MOVABLE_BUT_NOT_COPYABLE"kind="functionlike"><macro-parametername="TYPE"/><description><para>This macro marks a type as movable but not copyable, disabling copy construction and assignment. The user will need to write a move constructor/assignment as explained in the documentation to fully write a movable but not copyable class. </para></description></macro>
<macroname="BOOST_COPYABLE_AND_MOVABLE"kind="functionlike"><macro-parametername="TYPE"/><description><para>This macro marks a type as copyable and movable. The user will need to write a move constructor/assignment and a copy assignment as explained in the documentation to fully write a copyable and movable class. </para></description></macro>
<macroname="BOOST_RV_REF"kind="functionlike"><macro-parametername="TYPE"/><description><para>This macro is used to achieve portable syntax in move constructors and assignments for classes marked as BOOST_COPYABLE_AND_MOVABLE or BOOST_MOVABLE_BUT_NOT_COPYABLE </para></description></macro>
<macroname="BOOST_RV_REF_BEG"><description><para>This macro is used to achieve portable syntax in move constructors and assignments for template classes marked as BOOST_COPYABLE_AND_MOVABLE or BOOST_MOVABLE_BUT_NOT_COPYABLE. As macros have problems with comma-separated template arguments, the template argument must be preceded with BOOST_RV_REF_BEG and ended with BOOST_RV_REF_END </para></description></macro>
<macroname="BOOST_RV_REF_END"><description><para>This macro is used to achieve portable syntax in move constructors and assignments for template classes marked as BOOST_COPYABLE_AND_MOVABLE or BOOST_MOVABLE_BUT_NOT_COPYABLE. As macros have problems with comma-separated template arguments, the template argument must be preceded with BOOST_RV_REF_BEG and ended with BOOST_RV_REF_END </para></description></macro>
<macroname="BOOST_RV_REF_BEG_IF_CXX11"><description><para>This macro expands to BOOST_RV_REF_BEG if BOOST_NO_CXX11_RVALUE_REFERENCES is not defined, empty otherwise </para></description></macro>
<macroname="BOOST_RV_REF_END_IF_CXX11"><description><para>This macro expands to BOOST_RV_REF_END if BOOST_NO_CXX11_RVALUE_REFERENCES is not defined, empty otherwise </para></description></macro>
<macroname="BOOST_COPY_ASSIGN_REF"kind="functionlike"><macro-parametername="TYPE"/><description><para>This macro is used to achieve portable syntax in copy assignment for classes marked as BOOST_COPYABLE_AND_MOVABLE. </para></description></macro>
<macroname="BOOST_FWD_REF"kind="functionlike"><macro-parametername="TYPE"/><description><para>This macro is used to implement portable perfect forwarding as explained in the documentation. </para></description></macro>
<macroname="BOOST_MOVE_RET"kind="functionlike"><macro-parametername="RET_TYPE"/><macro-parametername="REF"/><description><para>This macro is used to achieve portable move return semantics. The C++11 Standard allows implicit move returns when the object to be returned is designated by a lvalue and:<itemizedlist>
</para><para>For C++11 conforming compilers this macros only yields to REF: <computeroutput>return BOOST_MOVE_RET(RET_TYPE, REF);</computeroutput> -><computeroutput>return REF;</computeroutput></para><para>For compilers without rvalue references this macro does an explicit move if the move emulation is activated and the return type (RET_TYPE) is not a reference.</para><para>For non-conforming compilers with rvalue references like Visual 2010 & 2012, an explicit move is performed if RET_TYPE is not a reference.</para><para><emphasisrole="bold">Caution</emphasis>: When using this macro in non-conforming or C++03 compilers, a move will be performed even if the C++11 standard does not allow it (e.g. returning a static variable). The user is responsible for using this macro only to return local objects that met C++11 criteria. </para></description></macro>
<macroname="BOOST_MOVE_BASE"kind="functionlike"><macro-parametername="BASE_TYPE"/><macro-parametername="ARG"/><purpose>defined(BOOST_MOVE_MSVC_AUTO_MOVE_RETURN_BUG) || defined(BOOST_MOVE_DOXYGEN_INVOKED) </purpose><description><para>This macro is used to achieve portable optimal move constructors.</para><para>When implementing the move constructor, in C++03 compilers the moved-from argument must be cast to the base type before calling <computeroutput>boost::move()</computeroutput> due to rvalue reference limitations.</para><para>In C++11 compilers the cast from a rvalue reference of a derived type to a rvalue reference of a base type is implicit. </para></description></macro>
</header>
<headername="boost/move/default_delete.hpp">
<para>Describes the default deleter (destruction policy) of <computeroutput>unique_ptr</computeroutput>: <computeroutput>default_delete</computeroutput>. </para><namespacename="boost">
<namespacename="movelib">
<structname="default_delete"><template>
<template-type-parametername="T"><purpose><para>The type to be deleted. It may be an incomplete type </para></purpose></template-type-parameter>
</template><description><para>The class template <computeroutput><classnamealt="boost::movelib::default_delete">default_delete</classname></computeroutput> serves as the default deleter (destruction policy) for the class template <computeroutput><classnamealt="boost::movelib::unique_ptr">unique_ptr</classname></computeroutput>.</para><para>
</para></description><method-groupname="public member functions">
</template><parametername="ptr"><paramtype>U *</paramtype></parameter><description><para><emphasisrole="bold">Effects</emphasis>: if T is not an array type, calls <computeroutput>delete</computeroutput> on static_cast<T*>(ptr), otherwise calls <computeroutput>delete[]</computeroutput> on static_cast<remove_extent<T>::type*>(ptr).</para><para><emphasisrole="bold">Remarks</emphasis>: If U is an incomplete type, the program is ill-formed. This operator shall not participate in overload resolution unless:<itemizedlist>
<listitem><para>T is not an array type and U* is convertible to T*, OR</para>
</listitem><listitem><para>T is an array type, and remove_cv<U>::type is the same type as remove_cv<remove_extent<T>::type>::type and U* is convertible to remove_extent<T>::type*. </para>
<methodname="operator()"cv="const noexcept"><type>void</type><parametername=""><paramtype>std::nullptr_t</paramtype></parameter><description><para><emphasisrole="bold">Effects</emphasis>: Same as <computeroutput>(<emphasis>this)(static_cast<element_type</emphasis>>(nullptr))</computeroutput>. </para></description></method>
</template><parametername=""><paramtype>const <classname>default_delete</classname>< U >&</paramtype></parameter><description><para><emphasisrole="bold">Effects</emphasis>: Constructs a <classnamealt="boost::movelib::default_delete">default_delete</classname> object from another <computeroutput><classnamealt="boost::movelib::default_delete">default_delete</classname><underline> object.</underline></computeroutput></para><para><computeroutput><underline><emphasisrole="bold">Remarks</emphasis>: This constructor shall not participate in overload resolution unless:<itemizedlist>
<listitem><para>If T is not an array type and U* is implicitly convertible to T*.</para>
</listitem><listitem><para>If T is an array type and U* is a more CV qualified pointer to remove_extent<T>::type. </para>
</template><parametername=""><paramtype>const <classname>default_delete</classname>< U >&</paramtype></parameter><description><para><emphasisrole="bold">Effects</emphasis>: Constructs a <classnamealt="boost::movelib::default_delete">default_delete</classname> object from another <computeroutput><classnamealt="boost::movelib::default_delete">default_delete</classname><underline> object.</underline></computeroutput></para><para><computeroutput><underline><emphasisrole="bold">Remarks</emphasis>: This constructor shall not participate in overload resolution unless:<itemizedlist>
<listitem><para>If T is not an array type and U* is implicitly convertible to T*.</para>
</listitem><listitem><para>If T is an array type and U* is a more CV qualified pointer to remove_extent<T>::type. </para>
</template><description><para>A move insert iterator that move constructs elements at the back of a container </para></description><typedefname="container_type"><type>C</type></typedef>
</template><description><para>A move insert iterator that move constructs elements int the front of a container </para></description><typedefname="container_type"><type>C</type></typedef>
</template><description><para>Class template <classnamealt="boost::move_iterator">move_iterator</classname> is an iterator adaptor with the same behavior as the underlying iterator except that its dereference operator implicitly converts the value returned by the underlying iterator's dereference operator to an rvalue reference. Some generic algorithms can be called with move iterators to replace copying with moving. </para></description><typedefname="iterator_type"><type>It</type></typedef>
<functionname="make_move_iterator"><type><classname>move_iterator</classname>< It ></type><template>
<template-type-parametername="It"/>
</template><parametername="it"><paramtype>const It &</paramtype></parameter><description><para><emphasisrole="bold">Returns</emphasis>: move_iterator<It>(i). </para></description></function>
<functionname="back_move_inserter"><type><classname>back_move_insert_iterator</classname>< C ></type><template>
<para>Defines "make_unique" functions, which are factories to create instances of unique_ptr depending on the passed arguments.</para><para>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 <computeroutput>unique_ptr.hpp</computeroutput></para><namespacename="boost">
<namespacename="movelib">
<functionname="make_unique"><type><classname>unique_ptr</classname>< T ></type><template>
</template><parametername="args"><paramtype>Args &&...</paramtype></parameter><description><para><emphasisrole="bold">Remarks</emphasis>: This function shall not participate in overload resolution unless T is not an array.</para><para><emphasisrole="bold">Returns</emphasis>: <computeroutput>unique_ptr<T>(new T(std::forward<Args>(args)...))</computeroutput>. </para></description></function>
<functionname="make_unique_nothrow"><type><classname>unique_ptr</classname>< T ></type><template>
</template><parametername="args"><paramtype>Args &&...</paramtype></parameter><description><para><emphasisrole="bold">Remarks</emphasis>: This function shall not participate in overload resolution unless T is not an array.</para><para><emphasisrole="bold">Returns</emphasis>: <computeroutput>unique_ptr<T>(new T(std::nothrow)(std::forward<Args>(args)...))</computeroutput>. </para></description></function>
<functionname="make_unique_definit"><type><classname>unique_ptr</classname>< T ></type><template>
<template-type-parametername="T"/>
</template><description><para><emphasisrole="bold">Remarks</emphasis>: This function shall not participate in overload resolution unless T is not an array.</para><para><emphasisrole="bold">Returns</emphasis>: <computeroutput>unique_ptr<T>(new T)</computeroutput> (default initialization) </para></description></function>
<functionname="make_unique_nothrow_definit"><type><classname>unique_ptr</classname>< T ></type><template>
<template-type-parametername="T"/>
</template><description><para><emphasisrole="bold">Remarks</emphasis>: This function shall not participate in overload resolution unless T is not an array.</para><para><emphasisrole="bold">Returns</emphasis>: <computeroutput>unique_ptr<T>(new T(std::nothrow)</computeroutput> (default initialization) </para></description></function>
<functionname="make_unique"><type><classname>unique_ptr</classname>< T ></type><template>
<template-type-parametername="T"/>
</template><parametername="n"><paramtype>std::size_t</paramtype></parameter><description><para><emphasisrole="bold">Remarks</emphasis>: This function shall not participate in overload resolution unless T is an array of unknown bound.</para><para><emphasisrole="bold">Returns</emphasis>: <computeroutput>unique_ptr<T>(new remove_extent_t<T>[n]())</computeroutput> (value initialization) </para></description></function>
<functionname="make_unique_nothrow"><type><classname>unique_ptr</classname>< T ></type><template>
<template-type-parametername="T"/>
</template><parametername="n"><paramtype>std::size_t</paramtype></parameter><description><para><emphasisrole="bold">Remarks</emphasis>: This function shall not participate in overload resolution unless T is an array of unknown bound.</para><para><emphasisrole="bold">Returns</emphasis>: <computeroutput>unique_ptr<T>(new (std::nothrow)remove_extent_t<T>[n]())</computeroutput> (value initialization) </para></description></function>
<functionname="make_unique_definit"><type><classname>unique_ptr</classname>< T ></type><template>
<template-type-parametername="T"/>
</template><parametername="n"><paramtype>std::size_t</paramtype></parameter><description><para><emphasisrole="bold">Remarks</emphasis>: This function shall not participate in overload resolution unless T is an array of unknown bound.</para><para><emphasisrole="bold">Returns</emphasis>: <computeroutput>unique_ptr<T>(new remove_extent_t<T>[n])</computeroutput> (default initialization) </para></description></function>
<functionname="make_unique_nothrow_definit"><type><classname>unique_ptr</classname>< T ></type><template>
<template-type-parametername="T"/>
</template><parametername="n"><paramtype>std::size_t</paramtype></parameter><description><para><emphasisrole="bold">Remarks</emphasis>: This function shall not participate in overload resolution unless T is an array of unknown bound.</para><para><emphasisrole="bold">Returns</emphasis>: <computeroutput>unique_ptr<T>(new (std::nothrow)remove_extent_t<T>[n])</computeroutput> (default initialization) </para></description></function>
</template><parametername="..."><paramtype>Args &&</paramtype></parameter><description><para><emphasisrole="bold">Remarks</emphasis>: This function shall not participate in overload resolution unless T is an array of known bound. </para></description></function>
</template><parametername="..."><paramtype>Args &&</paramtype></parameter><description><para><emphasisrole="bold">Remarks</emphasis>: This function shall not participate in overload resolution unless T is an array of known bound. </para></description></function>
</template><parametername="..."><paramtype>Args &&</paramtype></parameter><description><para><emphasisrole="bold">Remarks</emphasis>: This function shall not participate in overload resolution unless T is an array of known bound. </para></description></function>
</template><parametername="..."><paramtype>Args &&</paramtype></parameter><description><para><emphasisrole="bold">Remarks</emphasis>: This function shall not participate in overload resolution unless T is an array of known bound. </para></description></function>
</template><parametername="f"><paramtype>I</paramtype></parameter><parametername="l"><paramtype>I</paramtype></parameter><parametername="result"><paramtype>O</paramtype></parameter><description><para><emphasisrole="bold">Effects</emphasis>: Moves elements in the range [first,last) into the range [result,result + (last - first)) starting from first and proceeding to last. For each non-negative integer n < (last-first), performs *(result + n) = boost::move (*(first + n)).</para><para><emphasisrole="bold">Effects</emphasis>: result + (last - first).</para><para><emphasisrole="bold">Requires</emphasis>: result shall not be in the range [first,last).</para><para><emphasisrole="bold">Complexity</emphasis>: Exactly last - first move assignments. </para></description></function>
</template><parametername="f"><paramtype>I</paramtype></parameter><parametername="l"><paramtype>I</paramtype></parameter><parametername="result"><paramtype>O</paramtype></parameter><description><para><emphasisrole="bold">Effects</emphasis>: Moves elements in the range [first,last) into the range [result - (last-first),result) starting from last - 1 and proceeding to first. For each positive integer n <= (last - first), performs *(result - n) = boost::move(*(last - n)).</para><para><emphasisrole="bold">Requires</emphasis>: result shall not be in the range [first,last).</para><para><emphasisrole="bold">Returns</emphasis>: result - (last - first).</para><para><emphasisrole="bold">Complexity</emphasis>: Exactly last - first assignments. </para></description></function>
</template><description><para>If this trait yields to true (<emphasis><classnamealt="boost::has_trivial_destructor_after_move">has_trivial_destructor_after_move</classname><T>::value == true</emphasis>) means that if T is used as argument of a move construction/assignment, there is no need to call T's destructor. This optimization tipically is used to improve containers' performance.</para><para>By default this trait is true if the type has trivial destructor, every class should specialize this trait if it wants to improve performance when inserted in containers. </para></description></struct>
<para>Describes the smart pointer unique_ptr, a drop-in replacement for std::unique_ptr, usable also from C++03 compilers.</para><para>Main differences from std::unique_ptr to avoid heavy dependencies, specially in C++03 compilers:<itemizedlist>
<listitem><para><computeroutput>operator <</computeroutput> uses pointer <computeroutput>operator <</computeroutput>instead of <computeroutput>std::less<common_type></computeroutput>. This avoids dependencies on <computeroutput>std::common_type</computeroutput> and <computeroutput>std::less</computeroutput> (<computeroutput><type_traits>/<functional></computeroutput> headers). In C++03 this avoid pulling Boost.Typeof and other cascading dependencies. As in all Boost platforms <computeroutput>operator <</computeroutput> on raw pointers and other smart pointers provides strict weak ordering in practice this should not be a problem for users.</para>
</listitem><listitem><para>assignable from literal 0 for compilers without nullptr</para>
</listitem><listitem><para><computeroutput>unique_ptr<T[]></computeroutput> is constructible and assignable from <computeroutput>unique_ptr<U[]></computeroutput> if cv-less T and cv-less U are the same type and T is more CV qualified than U. </para>
<listitem><para>The default type for the template parameter D is <classnamealt="boost::movelib::default_delete">default_delete</classname>. A client-supplied template argument D shall be a function object type, lvalue-reference to function, or lvalue-reference to function object type for which, given a value d of type D and a value ptr of type unique_ptr<T, D>::pointer, the expression d(ptr) is valid and has the effect of disposing of the pointer as appropriate for that deleter.</para>
</listitem><listitem><para>If the deleter's type D is not a reference type, D shall satisfy the requirements of Destructible.</para>
</listitem><listitem><para>If the type <computeroutput>remove_reference<D>::type::pointer</computeroutput> exists, it shall satisfy the requirements of NullablePointer. </para>
</template><description><para>A unique pointer is an object that owns another object and manages that other object through a pointer.</para><para>More precisely, a unique pointer is an object u that stores a pointer to a second object p and will dispose of p when u is itself destroyed (e.g., when leaving block scope). In this context, u is said to own p.</para><para>The mechanism by which u disposes of p is known as p's associated deleter, a function object whose correct invocation results in p's appropriate disposition (typically its deletion).</para><para>Let the notation u.p denote the pointer stored by u, and let u.d denote the associated deleter. Upon request, u can reset (replace) u.p and u.d with another pointer and deleter, but must properly dispose of its owned object via the associated deleter before such replacement is considered completed.</para><para>Additionally, u can, upon request, transfer ownership to another unique pointer u2. Upon completion of such a transfer, the following postconditions hold:<itemizedlist>
</para><para>As in the case of a reset, u2 must properly dispose of its pre-transfer owned object via the pre-transfer associated deleter before the ownership transfer is considered complete.</para><para>Each object of a type U instantiated from the <classnamealt="boost::movelib::unique_ptr">unique_ptr</classname> template specified in this subclause has the strict ownership semantics, specified above, of a unique pointer. In partial satisfaction of these semantics, each such U is MoveConstructible and MoveAssignable, but is not CopyConstructible nor CopyAssignable. The template parameter T of <classnamealt="boost::movelib::unique_ptr">unique_ptr</classname> may be an incomplete type.</para><para>The uses of <classnamealt="boost::movelib::unique_ptr">unique_ptr</classname> include providing exception safety for dynamically allocated memory, passing ownership of dynamically allocated memory to a function, and returning dynamically allocated memory from a function.</para><para>If T is an array type (e.g. unique_ptr<MyType[]>) the interface is slightly altered:<itemizedlist>
<listitem><para>Pointers to types derived from T are rejected by the constructors, and by reset.</para>
</listitem><listitem><para>The observers <computeroutput>operator*</computeroutput> and <computeroutput>operator-></computeroutput> are not provided.</para>
</listitem><listitem><para>The indexing observer <computeroutput>operator[]</computeroutput> is provided.</para>
</para></description><typedefname="pointer"><description><para>If the type <computeroutput>remove_reference<D>::type::pointer</computeroutput> exists, then it shall be a synonym for <computeroutput>remove_reference<D>::type::pointer</computeroutput>. Otherwise it shall be a synonym for T*. </para></description><type>see_documentation</type></typedef>
<typedefname="element_type"><description><para>If T is an array type, then element_type is equal to T. Otherwise, if T is a type in the form U[], element_type is equal to U. </para></description><type>see_documentation</type></typedef>
<methodname="operator *"cv="const noexcept"><type>element_type &</type><description><para><emphasisrole="bold">Requires</emphasis>: <computeroutput>get() != nullptr</computeroutput>.</para><para><emphasisrole="bold">Returns</emphasis>: <computeroutput>*get()</computeroutput>.</para><para><emphasisrole="bold">Remarks</b: If T is an array type, the program is ill-formed. </emphasis></para></description></method>
<methodname="operator[]"cv="const noexcept"><type>element_type &</type><parametername="i"><paramtype>std::size_t</paramtype></parameter><description><para><emphasisrole="bold">Requires</emphasis>: i < the number of elements in the array to which the stored pointer points.</para><para><emphasisrole="bold">Returns</emphasis>: <computeroutput>get()[i]</computeroutput>.</para><para><emphasisrole="bold">Remarks</b: If T is not an array type, the program is ill-formed. </emphasis></para></description></method>
<methodname="operator->"cv="const noexcept"><type>pointer</type><description><para><emphasisrole="bold">Requires</emphasis>: <computeroutput>get() != nullptr</computeroutput>.</para><para><emphasisrole="bold">Returns</emphasis>: <computeroutput>get()</computeroutput>.</para><para><emphasisrole="bold">Note</emphasis>: use typically requires that T be a complete type.</para><para><emphasisrole="bold">Remarks</b: If T is an array type, the program is ill-formed. </emphasis></para></description></method>
<methodname="get"cv="const noexcept"><type>pointer</type><description><para><emphasisrole="bold">Returns</emphasis>: The stored pointer. </para></description></method>
<methodname="get_deleter"cv="noexcept"><type>D &</type><description><para><emphasisrole="bold">Returns</emphasis>: A reference to the stored deleter. </para></description></method>
<methodname="get_deleter"cv="const noexcept"><type>const D &</type><description><para><emphasisrole="bold">Returns</emphasis>: A reference to the stored deleter. </para></description></method>
<methodname="release"cv="noexcept"><type>pointer</type><description><para><emphasisrole="bold">Postcondition</emphasis>: <computeroutput>get() == nullptr</computeroutput>.</para><para><emphasisrole="bold">Returns</emphasis>: The value <computeroutput>get()</computeroutput> had at the start of the call to release. </para></description></method>
</template><parametername="p"><paramtype>Pointer</paramtype></parameter><description><para><emphasisrole="bold">Requires</emphasis>: The expression <computeroutput>get_deleter()(get())</computeroutput> shall be well formed, shall have well-defined behavior, and shall not throw exceptions.</para><para><emphasisrole="bold">Effects</emphasis>: assigns p to the stored pointer, and then if the old value of the stored pointer, old_p, was not equal to nullptr, calls <computeroutput>get_deleter()(old_p)</computeroutput>. Note: The order of these operations is significant because the call to <computeroutput>get_deleter()</computeroutput> may destroy *this.</para><para><emphasisrole="bold">Postconditions</emphasis>: <computeroutput>get() == p</computeroutput>. Note: The postcondition does not hold if the call to <computeroutput>get_deleter()</computeroutput> destroys *this since <computeroutput>this->get()</computeroutput> is no longer a valid expression.</para><para><emphasisrole="bold">Remarks</emphasis>: This constructor shall not participate in overload resolution unless:<itemizedlist>
<methodname="reset"cv="noexcept"><type>void</type><description><para><emphasisrole="bold">Requires</emphasis>: The expression <computeroutput>get_deleter()(get())</computeroutput> shall be well formed, shall have well-defined behavior, and shall not throw exceptions.</para><para><emphasisrole="bold">Effects</emphasis>: assigns nullptr to the stored pointer, and then if the old value of the stored pointer, old_p, was not equal to nullptr, calls <computeroutput>get_deleter()(old_p)</computeroutput>. Note: The order of these operations is significant because the call to <computeroutput>get_deleter()</computeroutput> may destroy *this.</para><para><emphasisrole="bold">Postconditions</emphasis>: <computeroutput>get() == p</computeroutput>. Note: The postcondition does not hold if the call to <computeroutput>get_deleter()</computeroutput> destroys *this since <computeroutput>this->get()</computeroutput> is no longer a valid expression. </para></description></method>
<methodname="reset"cv="noexcept"><type>void</type><parametername=""><paramtype>std::nullptr_t</paramtype></parameter><description><para><emphasisrole="bold">Effects</emphasis>: Same as <computeroutput>reset()</computeroutput></para></description></method>
<methodname="swap"cv="noexcept"><type>void</type><parametername="u"><paramtype><classname>unique_ptr</classname>&</paramtype></parameter><description><para><emphasisrole="bold">Requires</emphasis>: <computeroutput>get_deleter()</computeroutput> shall be swappable and shall not throw an exception under swap.</para><para><emphasisrole="bold">Effects</emphasis>: Invokes swap on the stored pointers and on the stored deleters of *this and u. </para></description></method>
<constructorcv="noexcept"><description><para><emphasisrole="bold">Requires</emphasis>: D shall satisfy the requirements of DefaultConstructible, and that construction shall not throw an exception.</para><para><emphasisrole="bold">Effects</emphasis>: Constructs a <classnamealt="boost::movelib::unique_ptr">unique_ptr</classname> object that owns nothing, value-initializing the stored pointer and the stored deleter.</para><para><emphasisrole="bold">Postconditions</emphasis>: <computeroutput>get() == nullptr</computeroutput>. <computeroutput>get_deleter()</computeroutput> returns a reference to the stored deleter.</para><para><emphasisrole="bold">Remarks</emphasis>: If this constructor is instantiated with a pointer type or reference type for the template argument D, the program is ill-formed. </para></description></constructor>
<constructorcv="noexcept"><parametername=""><paramtype>std::nullptr_t</paramtype></parameter><description><para><emphasisrole="bold">Effects</emphasis>: Same as <computeroutput>unique_ptr()</computeroutput> (default constructor). </para></description></constructor>
</template><parametername="p"><paramtype>Pointer</paramtype></parameter><description><para><emphasisrole="bold">Requires</emphasis>: D shall satisfy the requirements of DefaultConstructible, and that construction shall not throw an exception.</para><para><emphasisrole="bold">Effects</emphasis>: Constructs a <classnamealt="boost::movelib::unique_ptr">unique_ptr</classname> which owns p, initializing the stored pointer with p and value initializing the stored deleter.</para><para><emphasisrole="bold">Postconditions</emphasis>: <computeroutput>get() == p</computeroutput>. <computeroutput>get_deleter()</computeroutput> returns a reference to the stored deleter.</para><para><emphasisrole="bold">Remarks</emphasis>: If this constructor is instantiated with a pointer type or reference type for the template argument D, the program is ill-formed. This constructor shall not participate in overload resolution unless:<itemizedlist>
</template><parametername="p"><paramtype>Pointer</paramtype></parameter><parametername="d1"><paramtype>see_documentation</paramtype></parameter><description><para>The signature of this constructor depends upon whether D is a reference type.<itemizedlist>
<listitem><para>If D is non-reference type A, then the signature is <computeroutput>unique_ptr(pointer p, const A& d)</computeroutput>.</para>
</listitem><listitem><para>If D is an lvalue-reference type A&, then the signature is <computeroutput>unique_ptr(pointer p, A& d)</computeroutput>.</para>
</listitem><listitem><para>If D is an lvalue-reference type const A&, then the signature is <computeroutput>unique_ptr(pointer p, const A& d)</computeroutput>.</para>
<listitem><para>D is not an lvalue-reference type and d is an lvalue or const rvalue. D shall satisfy the requirements of CopyConstructible, and the copy constructor of D shall not throw an exception. This <classnamealt="boost::movelib::unique_ptr">unique_ptr</classname> will hold a copy of d.</para>
</listitem><listitem><para>D is an lvalue-reference type and d is an lvalue. the type which D references need not be CopyConstructible nor MoveConstructible. This <classnamealt="boost::movelib::unique_ptr">unique_ptr</classname> will hold a D which refers to the lvalue d.</para>
</para><para><emphasisrole="bold">Effects</emphasis>: Constructs a <classnamealt="boost::movelib::unique_ptr">unique_ptr</classname> object which owns p, initializing the stored pointer with p and initializing the deleter as described above.</para><para><emphasisrole="bold">Postconditions</emphasis>: <computeroutput>get() == p</computeroutput>. <computeroutput>get_deleter()</computeroutput> returns a reference to the stored deleter. If D is a reference type then <computeroutput>get_deleter()</computeroutput> returns a reference to the lvalue d.</para><para><emphasisrole="bold">Remarks</emphasis>: This constructor shall not participate in overload resolution unless:<itemizedlist>
<constructorcv="noexcept"><parametername=""><paramtype>std::nullptr_t</paramtype></parameter><parametername="d1"><paramtype>see_documentation</paramtype></parameter><description><para><emphasisrole="bold">Effects</emphasis>: Same effects as <computeroutput>template<class Pointer> unique_ptr(Pointer p, deleter_arg_type1 d1)</computeroutput> and additionally <computeroutput>get() == nullptr</computeroutput></para></description></constructor>
<constructorcv="noexcept"><template>
<template-type-parametername="Pointer"/>
</template><parametername="p"><paramtype>Pointer</paramtype></parameter><parametername="d2"><paramtype>see_documentation</paramtype></parameter><description><para>The signature of this constructor depends upon whether D is a reference type.<itemizedlist>
<listitem><para>If D is non-reference type A, then the signature is <computeroutput>unique_ptr(pointer p, A&& d)</computeroutput>.</para>
</listitem><listitem><para>If D is an lvalue-reference type A&, then the signature is <computeroutput>unique_ptr(pointer p, A&& d)</computeroutput>.</para>
</listitem><listitem><para>If D is an lvalue-reference type const A&, then the signature is <computeroutput>unique_ptr(pointer p, const A&& d)</computeroutput>.</para>
<listitem><para>D is not an lvalue-reference type and d is a non-const rvalue. D shall satisfy the requirements of MoveConstructible, and the move constructor of D shall not throw an exception. This <classnamealt="boost::movelib::unique_ptr">unique_ptr</classname> will hold a value move constructed from d.</para>
</listitem><listitem><para>D is an lvalue-reference type and d is an rvalue, the program is ill-formed.</para>
</para><para><emphasisrole="bold">Effects</emphasis>: Constructs a <classnamealt="boost::movelib::unique_ptr">unique_ptr</classname> object which owns p, initializing the stored pointer with p and initializing the deleter as described above.</para><para><emphasisrole="bold">Postconditions</emphasis>: <computeroutput>get() == p</computeroutput>. <computeroutput>get_deleter()</computeroutput> returns a reference to the stored deleter. If D is a reference type then <computeroutput>get_deleter()</computeroutput> returns a reference to the lvalue d.</para><para><emphasisrole="bold">Remarks</emphasis>: This constructor shall not participate in overload resolution unless:<itemizedlist>
<constructorcv="noexcept"><parametername=""><paramtype>std::nullptr_t</paramtype></parameter><parametername="d2"><paramtype>see_documentation</paramtype></parameter><description><para><emphasisrole="bold">Effects</emphasis>: Same effects as <computeroutput>template<class Pointer> unique_ptr(Pointer p, deleter_arg_type2 d2)</computeroutput> and additionally <computeroutput>get() == nullptr</computeroutput></para></description></constructor>
<constructorcv="noexcept"><parametername="u"><paramtype><classname>unique_ptr</classname>&&</paramtype></parameter><description><para><emphasisrole="bold">Requires</emphasis>: If D is not a reference type, D shall satisfy the requirements of MoveConstructible. Construction of the deleter from an rvalue of type D shall not throw an exception.</para><para><emphasisrole="bold">Effects</emphasis>: Constructs a <classnamealt="boost::movelib::unique_ptr">unique_ptr</classname> by transferring ownership from u to *this. If D is a reference type, this deleter is copy constructed from u's deleter; otherwise, this deleter is move constructed from u's deleter.</para><para><emphasisrole="bold">Postconditions</emphasis>: <computeroutput>get()</computeroutput> yields the value u.get() yielded before the construction. <computeroutput>get_deleter()</computeroutput> returns a reference to the stored deleter that was constructed from u.get_deleter(). If D is a reference type then <computeroutput>get_deleter()</computeroutput> and <computeroutput>u.get_deleter()</computeroutput> both reference the same lvalue deleter. </para></description></constructor>
<constructorcv="noexcept"><template>
<template-type-parametername="U"/>
<template-type-parametername="E"/>
</template><parametername="u"><paramtype>BOOST_RV_REF_BEG_IF_CXX11 <classname>unique_ptr</classname>< U, E > BOOST_RV_REF_END_IF_CXX11</paramtype></parameter><description><para><emphasisrole="bold">Requires</emphasis>: If E is not a reference type, construction of the deleter from an rvalue of type E shall be well formed and shall not throw an exception. Otherwise, E is a reference type and construction of the deleter from an lvalue of type E shall be well formed and shall not throw an exception.</para><para><emphasisrole="bold">Remarks</emphasis>: This constructor shall not participate in overload resolution unless:<itemizedlist>
<listitem><para><computeroutput>unique_ptr<U, E>::pointer</computeroutput> is implicitly convertible to pointer,</para>
</listitem><listitem><para>U is not an array type, and</para>
</listitem><listitem><para>either D is a reference type and E is the same type as D, or D is not a reference type and E is implicitly convertible to D.</para>
</para><para><emphasisrole="bold">Effects</emphasis>: Constructs a <classnamealt="boost::movelib::unique_ptr">unique_ptr</classname> by transferring ownership from u to *this. If E is a reference type, this deleter is copy constructed from u's deleter; otherwise, this deleter is move constructed from u's deleter.</para><para><emphasisrole="bold">Postconditions</emphasis>: <computeroutput>get()</computeroutput> yields the value <computeroutput>u.get()</computeroutput> yielded before the construction. <computeroutput>get_deleter()</computeroutput> returns a reference to the stored deleter that was constructed from <computeroutput>u.get_deleter()</computeroutput>. </para></description></constructor>
<destructor><description><para><emphasisrole="bold">Requires</emphasis>: The expression <computeroutput>get_deleter()(get())</computeroutput> shall be well formed, shall have well-defined behavior, and shall not throw exceptions.</para><para><emphasisrole="bold">Effects</emphasis>: If <computeroutput>get() == nullpt1r</computeroutput> there are no effects. Otherwise <computeroutput>get_deleter()(get())</computeroutput>.</para><para><emphasisrole="bold">Note</emphasis>: The use of <classnamealt="boost::movelib::default_delete">default_delete</classname> requires T to be a complete type </para></description></destructor>
<copy-assignmentcv="noexcept"><type><classname>unique_ptr</classname>&</type><parametername="u"><paramtype><classname>unique_ptr</classname>&&</paramtype></parameter><description><para><emphasisrole="bold">Requires</emphasis>: If D is not a reference type, D shall satisfy the requirements of MoveAssignable and assignment of the deleter from an rvalue of type D shall not throw an exception. Otherwise, D is a reference type; <computeroutput>remove_reference<D>::type</computeroutput> shall satisfy the CopyAssignable requirements and assignment of the deleter from an lvalue of type D shall not throw an exception.</para><para><emphasisrole="bold">Effects</emphasis>: Transfers ownership from u to *this as if by calling <computeroutput>reset(u.release())</computeroutput> followed by <computeroutput>get_deleter() = std::forward<D>(u.get_deleter())</computeroutput>.</para><para><emphasisrole="bold">Returns</emphasis>: *this. </para></description></copy-assignment>
</template><parametername="u"><paramtype><classname>unique_ptr</classname>< U, E >&&</paramtype></parameter><description><para><emphasisrole="bold">Requires</emphasis>: If E is not a reference type, assignment of the deleter from an rvalue of type E shall be well-formed and shall not throw an exception. Otherwise, E is a reference type and assignment of the deleter from an lvalue of type E shall be well-formed and shall not throw an exception.</para><para><emphasisrole="bold">Remarks</emphasis>: This operator shall not participate in overload resolution unless:<itemizedlist>
</para><para><emphasisrole="bold">Effects</emphasis>: Transfers ownership from u to *this as if by calling <computeroutput>reset(u.release())</computeroutput> followed by <computeroutput>get_deleter() = std::forward<E>(u.get_deleter())</computeroutput>.</para><para><emphasisrole="bold">Returns</emphasis>: *this. </para></description></copy-assignment>
</template><parametername="x"><paramtype><classname>unique_ptr</classname>< T, D >&</paramtype></parameter><parametername="y"><paramtype><classname>unique_ptr</classname>< T, D >&</paramtype></parameter><description><para><emphasisrole="bold">Effects</emphasis>: Calls <computeroutput>x.swap(y)</computeroutput>. </para></description></function>
<para>This header includes core utilities from <computeroutput><boost/move/utility_core.hpp></computeroutput> and defines some more advanced utilities such as: </para><namespacename="boost">
</template><parametername=""><paramtype>input_reference</paramtype></parameter><description><para>This function provides a way to convert a reference into a rvalue reference in compilers with rvalue references. For other compilers converts T & into <emphasis>::boost::rv<T>&</emphasis> so that move emulation is activated. Reference would be converted to rvalue reference only if input type is nothrow move constructible or if it has no copy constructor. In all other cases const reference would be returned </para></description></function>
<para>This header defines core utilities to ease the development of move-aware functions. This header minimizes dependencies from other libraries. </para><namespacename="boost">
</template><description><para>This trait's internal boolean <computeroutput>value</computeroutput> is false in compilers with rvalue references and true in compilers without rvalue references.</para><para>A user can specialize this trait for a type T to false to SFINAE out <computeroutput>move</computeroutput> and <computeroutput>forward</computeroutput> so that the user can define a different move emulation for that type in namespace boost (e.g. another Boost library for its types) and avoid any overload ambiguity. </para></description><data-membername="value"specifiers="static"><type>const bool</type></data-member>
</template><parametername=""><paramtype>input_reference</paramtype></parameter><description><para>This function provides a way to convert a reference into a rvalue reference in compilers with rvalue references. For other compilers if <computeroutput>T</computeroutput> is Boost.Move enabled type then it converts <computeroutput>T&</computeroutput> into <computeroutput>::boost::rv<T>&</computeroutput> so that move emulation is activated, else it returns <computeroutput>T &</computeroutput>. </para></description></function>
</template><parametername=""><paramtype>input_reference</paramtype></parameter><description><para>This function provides limited form of forwarding that is usually enough for in-place construction and avoids the exponential overloading for achieve the limited forwarding in C++03.</para><para>For compilers with rvalue references this function provides perfect forwarding.</para><para>Otherwise:<itemizedlist>
</template><parametername=""><paramtype>input_reference</paramtype></parameter><description><para><emphasisrole="bold">Effects</emphasis>: Calls <computeroutput>boost::move</computeroutput> if <computeroutput>input_reference</computeroutput> is not a lvalue reference. Otherwise returns the reference </para></description></function>