HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_UniquePtr.h File Reference
#include <stddef.h>
#include <memory>
#include <type_traits>
#include <utility>
+ Include dependency graph for UT_UniquePtr.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  UT::DefaultClearer< T >
 
struct  UT::DefaultClearer< UT_UniquePtr< T > >
 

Namespaces

 UT
 

Typedefs

template<class T , class Deleter = std::default_delete<T>>
using UT_UniquePtr = std::unique_ptr< T, Deleter >
 A smart pointer for unique ownership of dynamically allocated objects. More...
 

Functions

template<class T , class... REST, std::enable_if_t<!std::is_array_v< T >, int > = 0>
UT_UniquePtr< T > UTmakeUnique (REST &&...args)
 
template<class T , std::enable_if_t< std::is_array_v< T > &&std::extent_v< T >==0, int > = 0>
UT_UniquePtr< T > UTmakeUnique (size_t len)
 Construct a value initialized 1D array of type T with len elements. More...
 
template<class T , class... REST, std::enable_if_t< std::extent_v< T >!=0, int > = 0>
void UTmakeUnique (REST &&...)=delete
 Construction of arrays of known bound is disallowed. Just do it directly! More...
 
template<class T , std::enable_if_t<!std::is_array_v< T >, int > = 0>
UT_UniquePtr< T > UTmakeUniqueForOverwrite ()
 Construct a default initialized T in a UT_UniquePtr. More...
 
template<class T , std::enable_if_t< std::is_array_v< T > &&std::extent_v< T >==0, int > = 0>
UT_UniquePtr< T > UTmakeUniqueForOverwrite (size_t len)
 Construct a default initialized 1D array of type T with len elements. More...
 
template<class T , class... REST, std::enable_if_t< std::extent_v< T >!=0, int > = 0>
void UTmakeUniqueForOverwrite (REST &&...)=delete
 Construction of arrays of known bound is disallowed. Just do it directly! More...
 

Typedef Documentation

template<class T , class Deleter = std::default_delete<T>>
using UT_UniquePtr = std::unique_ptr<T, Deleter>

A smart pointer for unique ownership of dynamically allocated objects.

UT_UniquePtr mimics a built-in pointer except that it guarantees deletion of the object pointed to, either upon destruction or via an explicit reset(). UT_UniquePtr is a simple solution for simple needs; use UT_SharedPtr/UT_IntrusivePtr if your needs are more complex.

Definition at line 39 of file UT_UniquePtr.h.

Function Documentation

template<class T , class... REST, std::enable_if_t<!std::is_array_v< T >, int > = 0>
UT_UniquePtr<T> UTmakeUnique ( REST &&...  args)
inline

Constructs an object of type T and wraps it in an UT_UniquePtr. The args are passed to the constructor of T.

Definition at line 50 of file UT_UniquePtr.h.

template<class T , std::enable_if_t< std::is_array_v< T > &&std::extent_v< T >==0, int > = 0>
UT_UniquePtr<T> UTmakeUnique ( size_t  len)
inline

Construct a value initialized 1D array of type T with len elements.

Definition at line 61 of file UT_UniquePtr.h.

template<class T , class... REST, std::enable_if_t< std::extent_v< T >!=0, int > = 0>
void UTmakeUnique ( REST &&  ...)
delete

Construction of arrays of known bound is disallowed. Just do it directly!

template<class T , std::enable_if_t<!std::is_array_v< T >, int > = 0>
UT_UniquePtr<T> UTmakeUniqueForOverwrite ( )
inline

Construct a default initialized T in a UT_UniquePtr.

Definition at line 81 of file UT_UniquePtr.h.

template<class T , std::enable_if_t< std::is_array_v< T > &&std::extent_v< T >==0, int > = 0>
UT_UniquePtr<T> UTmakeUniqueForOverwrite ( size_t  len)
inline

Construct a default initialized 1D array of type T with len elements.

Definition at line 92 of file UT_UniquePtr.h.

template<class T , class... REST, std::enable_if_t< std::extent_v< T >!=0, int > = 0>
void UTmakeUniqueForOverwrite ( REST &&  ...)
delete

Construction of arrays of known bound is disallowed. Just do it directly!