Extended CUDA Library (ecuda)  2.0
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
Public Types | Public Member Functions | List of all members
ecuda::unique_ptr< T, Deleter > Class Template Reference

A smart pointer that retains sole ownership of an object. More...

#include <unique_ptr.hpp>

Public Types

typedef T element_type
 
typedef ecuda::add_pointer< T >
::type 
pointer
 
typedef Deleter deleter_type
 

Public Member Functions

__HOST__ __DEVICE__ __CONSTEXPR__ unique_ptr () __NOEXCEPT__
 
__HOST__ __DEVICE__ unique_ptr (T *ptr) __NOEXCEPT__
 
__HOST__ __DEVICE__ unique_ptr (T *ptr, Deleter deleter) __NOEXCEPT__
 
__HOST__ __DEVICE__ ~unique_ptr ()
 
__HOST__ __DEVICE__ pointer release () __NOEXCEPT__
 
__HOST__ __DEVICE__ void reset (pointer ptr=pointer()) __NOEXCEPT__
 
__HOST__ __DEVICE__ void swap (unique_ptr &other) __NOEXCEPT__
 
__HOST__ __DEVICE__ pointer get () const
 
__HOST__ __DEVICE__ deleter_typeget_deleter ()
 
__HOST__ __DEVICE__ const
deleter_type
get_deleter () const
 
__HOST__ __DEVICE__ operator bool () const
 
__DEVICE__
ecuda::add_lvalue_reference< T >
::type 
operator* () const __NOEXCEPT__
 
__HOST__ __DEVICE__ pointer operator-> () const __NOEXCEPT__
 
__DEVICE__
ecuda::add_lvalue_reference< T >
::type 
operator[] (std::size_t i) const
 
template<typename T2 , class D2 >
__HOST__ __DEVICE__ bool operator== (const unique_ptr< T2, D2 > &other) const
 
template<typename T2 , class D2 >
__HOST__ __DEVICE__ bool operator!= (const unique_ptr< T2, D2 > &other) const
 
template<typename T2 , class D2 >
__HOST__ __DEVICE__ bool operator< (const unique_ptr< T2, D2 > &other) const
 
template<typename T2 , class D2 >
__HOST__ __DEVICE__ bool operator> (const unique_ptr< T2, D2 > &other) const
 
template<typename T2 , class D2 >
__HOST__ __DEVICE__ bool operator<= (const unique_ptr< T2, D2 > &other) const
 
template<typename T2 , class D2 >
__HOST__ __DEVICE__ bool operator>= (const unique_ptr< T2, D2 > &other) const
 

Detailed Description

template<typename T, class Deleter = default_device_delete<T>>
class ecuda::unique_ptr< T, Deleter >

A smart pointer that retains sole ownership of an object.

ecuda::unique_ptr is a smart pointer that retains sole ownership of a device object through a pointer and destroys that object when the unique_ptr goes out of scope. No two unique_ptr instances can manage the same object.

The object is destroyed and its memory deallocated when either of the following happens:

The object is destroyed using a potentially user-supplied deleter by calling Deleter(ptr). The deleter calls the destructor of the object and dispenses the memory.

A unique_ptr may alternatively own no object, in which case it is called empty.

There is no separate specialization of unique_ptr for dynamically-allocated arrays of objects (i.e. T[]) since the underlying CUDA API makes no distinction between individual objects versus arrays in terms of memory allocation/deallocation.

The class satisfies the requirements of MoveConstructible and MoveAssignable, but not the requirements of either CopyConstructible or CopyAssignable.

Deleter must be Functionobject or lvalue_reference to a FunctionObject or lvalue reference to function, callable with an argument of type unique_ptr<T,Deleter>::pointer.

Definition at line 84 of file unique_ptr.hpp.

Member Typedef Documentation

template<typename T, class Deleter = default_device_delete<T>>
typedef Deleter ecuda::unique_ptr< T, Deleter >::deleter_type

Definition at line 102 of file unique_ptr.hpp.

template<typename T, class Deleter = default_device_delete<T>>
typedef T ecuda::unique_ptr< T, Deleter >::element_type

Definition at line 100 of file unique_ptr.hpp.

template<typename T, class Deleter = default_device_delete<T>>
typedef ecuda::add_pointer<T>::type ecuda::unique_ptr< T, Deleter >::pointer

Definition at line 101 of file unique_ptr.hpp.

Constructor & Destructor Documentation

template<typename T, class Deleter = default_device_delete<T>>
__HOST__ __DEVICE__ __CONSTEXPR__ ecuda::unique_ptr< T, Deleter >::unique_ptr ( )
inline

Definition at line 112 of file unique_ptr.hpp.

template<typename T, class Deleter = default_device_delete<T>>
__HOST__ __DEVICE__ ecuda::unique_ptr< T, Deleter >::unique_ptr ( T *  ptr)
inlineexplicit

Definition at line 113 of file unique_ptr.hpp.

template<typename T, class Deleter = default_device_delete<T>>
__HOST__ __DEVICE__ ecuda::unique_ptr< T, Deleter >::unique_ptr ( T *  ptr,
Deleter  deleter 
)
inline

Definition at line 114 of file unique_ptr.hpp.

template<typename T, class Deleter = default_device_delete<T>>
__HOST__ __DEVICE__ ecuda::unique_ptr< T, Deleter >::~unique_ptr ( )
inline

Definition at line 121 of file unique_ptr.hpp.

Member Function Documentation

template<typename T, class Deleter = default_device_delete<T>>
__HOST__ __DEVICE__ pointer ecuda::unique_ptr< T, Deleter >::get ( ) const
inline

Definition at line 158 of file unique_ptr.hpp.

template<typename T, class Deleter = default_device_delete<T>>
__HOST__ __DEVICE__ deleter_type& ecuda::unique_ptr< T, Deleter >::get_deleter ( )
inline

Definition at line 160 of file unique_ptr.hpp.

template<typename T, class Deleter = default_device_delete<T>>
__HOST__ __DEVICE__ const deleter_type& ecuda::unique_ptr< T, Deleter >::get_deleter ( ) const
inline

Definition at line 161 of file unique_ptr.hpp.

template<typename T, class Deleter = default_device_delete<T>>
__HOST__ __DEVICE__ ecuda::unique_ptr< T, Deleter >::operator bool ( ) const
inline

Definition at line 166 of file unique_ptr.hpp.

template<typename T, class Deleter = default_device_delete<T>>
template<typename T2 , class D2 >
__HOST__ __DEVICE__ bool ecuda::unique_ptr< T, Deleter >::operator!= ( const unique_ptr< T2, D2 > &  other) const
inline

Definition at line 179 of file unique_ptr.hpp.

template<typename T, class Deleter = default_device_delete<T>>
__DEVICE__ ecuda::add_lvalue_reference<T>::type ecuda::unique_ptr< T, Deleter >::operator* ( ) const
inline

Definition at line 169 of file unique_ptr.hpp.

template<typename T, class Deleter = default_device_delete<T>>
__HOST__ __DEVICE__ pointer ecuda::unique_ptr< T, Deleter >::operator-> ( ) const
inline

Definition at line 171 of file unique_ptr.hpp.

template<typename T, class Deleter = default_device_delete<T>>
template<typename T2 , class D2 >
__HOST__ __DEVICE__ bool ecuda::unique_ptr< T, Deleter >::operator< ( const unique_ptr< T2, D2 > &  other) const
inline

Definition at line 180 of file unique_ptr.hpp.

template<typename T, class Deleter = default_device_delete<T>>
template<typename T2 , class D2 >
__HOST__ __DEVICE__ bool ecuda::unique_ptr< T, Deleter >::operator<= ( const unique_ptr< T2, D2 > &  other) const
inline

Definition at line 182 of file unique_ptr.hpp.

template<typename T, class Deleter = default_device_delete<T>>
template<typename T2 , class D2 >
__HOST__ __DEVICE__ bool ecuda::unique_ptr< T, Deleter >::operator== ( const unique_ptr< T2, D2 > &  other) const
inline

Definition at line 178 of file unique_ptr.hpp.

template<typename T, class Deleter = default_device_delete<T>>
template<typename T2 , class D2 >
__HOST__ __DEVICE__ bool ecuda::unique_ptr< T, Deleter >::operator> ( const unique_ptr< T2, D2 > &  other) const
inline

Definition at line 181 of file unique_ptr.hpp.

template<typename T, class Deleter = default_device_delete<T>>
template<typename T2 , class D2 >
__HOST__ __DEVICE__ bool ecuda::unique_ptr< T, Deleter >::operator>= ( const unique_ptr< T2, D2 > &  other) const
inline

Definition at line 183 of file unique_ptr.hpp.

template<typename T, class Deleter = default_device_delete<T>>
__DEVICE__ ecuda::add_lvalue_reference<T>::type ecuda::unique_ptr< T, Deleter >::operator[] ( std::size_t  i) const
inline

Definition at line 173 of file unique_ptr.hpp.

template<typename T, class Deleter = default_device_delete<T>>
__HOST__ __DEVICE__ pointer ecuda::unique_ptr< T, Deleter >::release ( )
inline

Definition at line 144 of file unique_ptr.hpp.

template<typename T, class Deleter = default_device_delete<T>>
__HOST__ __DEVICE__ void ecuda::unique_ptr< T, Deleter >::reset ( pointer  ptr = pointer())
inline

Definition at line 150 of file unique_ptr.hpp.

template<typename T, class Deleter = default_device_delete<T>>
__HOST__ __DEVICE__ void ecuda::unique_ptr< T, Deleter >::swap ( unique_ptr< T, Deleter > &  other)
inline

Definition at line 156 of file unique_ptr.hpp.


The documentation for this class was generated from the following file: