2.6.0
Freundlich's C++ toolkit
Public Types | Public Member Functions
fcppt::unique_ptr< Type, Deleter > Class Template Reference

Detailed Description

template<typename Type, typename Deleter>
class fcppt::unique_ptr< Type, Deleter >

A simpler unique_ptr that shouldn't be used as a null pointer.

std::unique_ptr can easily be used as a null pointer because it has a default constructor and also a reset function. Null pointers should always be handled by optional references instead (see fcppt.optional). While it is not possible to completely forbid unique pointers that are null, this class makes it harder to do so. Unique pointers that have been moved from are still null because a unique pointer must track its ownership status. Make sure not to access such pointers.

Public Types

typedef Type element_type
 
typedef element_typepointer
 
typedef Deleter deleter_type
 

Public Member Functions

 unique_ptr (pointer) noexcept
 
 unique_ptr (unique_ptr &&) noexcept
 
unique_ptroperator= (unique_ptr &&) noexcept
 
 ~unique_ptr ()
 
std::add_lvalue_reference< Type >::type operator* () const noexcept
 
pointer operator-> () const noexcept
 
pointer get_pointer () const noexcept
 
pointer release_ownership () noexcept
 Releases ownerhsip. More...
 

Member Typedef Documentation

◆ deleter_type

template<typename Type , typename Deleter >
typedef Deleter fcppt::unique_ptr< Type, Deleter >::deleter_type

◆ element_type

template<typename Type , typename Deleter >
typedef Type fcppt::unique_ptr< Type, Deleter >::element_type

◆ pointer

template<typename Type , typename Deleter >
typedef element_type* fcppt::unique_ptr< Type, Deleter >::pointer

Constructor & Destructor Documentation

◆ unique_ptr() [1/2]

template<typename Type , typename Deleter >
fcppt::unique_ptr< Type, Deleter >::unique_ptr ( pointer  )
explicitnoexcept

◆ unique_ptr() [2/2]

template<typename Type , typename Deleter >
fcppt::unique_ptr< Type, Deleter >::unique_ptr ( unique_ptr< Type, Deleter > &&  )
noexcept

◆ ~unique_ptr()

template<typename Type , typename Deleter >
fcppt::unique_ptr< Type, Deleter >::~unique_ptr ( )

Member Function Documentation

◆ get_pointer()

template<typename Type , typename Deleter >
pointer fcppt::unique_ptr< Type, Deleter >::get_pointer ( ) const
noexcept

◆ operator*()

template<typename Type , typename Deleter >
std::add_lvalue_reference< Type >::type fcppt::unique_ptr< Type, Deleter >::operator* ( ) const
noexcept

◆ operator->()

template<typename Type , typename Deleter >
pointer fcppt::unique_ptr< Type, Deleter >::operator-> ( ) const
noexcept

◆ operator=()

template<typename Type , typename Deleter >
unique_ptr& fcppt::unique_ptr< Type, Deleter >::operator= ( unique_ptr< Type, Deleter > &&  )
noexcept

◆ release_ownership()

template<typename Type , typename Deleter >
pointer fcppt::unique_ptr< Type, Deleter >::release_ownership ( )
noexcept

Releases ownerhsip.

This can be used to move the pointer to another class that takes over ownership. Use this with extreme caution.