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

Go to the source code of this file.

Classes

struct  UT::detail::is_unbounded_array< T >
 
struct  UT::detail::is_unbounded_array< T[]>
 
struct  UT::detail::is_bounded_array< T >
 
struct  UT::detail::is_bounded_array< T[N]>
 
struct  UT::DefaultClearer< T >
 
struct  UT::DefaultClearer< UT_SharedPtr< T > >
 

Namespaces

 UT
 
 UT::detail
 

Macros

#define UTallocateShared   std::allocate_shared
 
#define UTstatic_pointer_cast   std::static_pointer_cast
 
#define UTdynamic_pointer_cast   std::dynamic_pointer_cast
 
#define UTconst_pointer_cast   std::const_pointer_cast
 
#define UTreinterpret_pointer_cast   std::reinterpret_pointer_cast
 

Typedefs

template<typename T >
using UT_SharedPtr = std::shared_ptr< T >
 Wrapper around std::shared_ptr. More...
 
template<typename T >
using UTenable_shared_from_this = std::enable_shared_from_this< T >
 
template<typename T >
using UT_WeakPtr = std::weak_ptr< T >
 

Functions

template<typename T >
UT_SharedPtr< T > UTmakeSharedArrayPtr (size_t len)
 
template<typename T , typename... Args>
std::enable_if_t
< !std::is_array< T >::value,
UT_SharedPtr< T >> 
UTmakeShared (Args &&...args)
 Create UT_SharedPtr<T> to T constructed with args. More...
 
template<typename T >
std::enable_if_t
< UT::detail::is_unbounded_array
< T >::value, UT_SharedPtr< T >> 
UTmakeShared (size_t len)
 
template<typename T >
std::enable_if_t
< UT::detail::is_bounded_array
< T >::value, UT_SharedPtr< T >> 
UTmakeShared ()
 

Macro Definition Documentation

#define UTallocateShared   std::allocate_shared

Definition at line 41 of file UT_SharedPtr.h.

#define UTconst_pointer_cast   std::const_pointer_cast

Definition at line 45 of file UT_SharedPtr.h.

#define UTdynamic_pointer_cast   std::dynamic_pointer_cast

Definition at line 44 of file UT_SharedPtr.h.

#define UTreinterpret_pointer_cast   std::reinterpret_pointer_cast

Definition at line 46 of file UT_SharedPtr.h.

#define UTstatic_pointer_cast   std::static_pointer_cast

Definition at line 43 of file UT_SharedPtr.h.

Typedef Documentation

template<typename T >
using UT_SharedPtr = std::shared_ptr<T>

Wrapper around std::shared_ptr.

An shared pointer takes ownership of the object referenced. The reference counting is done outside the object interface, so the size of a UT_SharedPtr is larger than a vanilla pointer.

As this is a wrapper around the boost shared pointer template, the type (T) must have a Copy Constructor and a valid Assignment Operator

See Also
UT_IntrusivePtr

Definition at line 36 of file UT_SharedPtr.h.

template<typename T >
using UT_WeakPtr = std::weak_ptr<T>

Definition at line 49 of file UT_SharedPtr.h.

template<typename T >
using UTenable_shared_from_this = std::enable_shared_from_this<T>

Definition at line 39 of file UT_SharedPtr.h.

Function Documentation

template<typename T , typename... Args>
std::enable_if_t< !std::is_array<T>::value, UT_SharedPtr<T>> UTmakeShared ( Args &&...  args)
inline

Create UT_SharedPtr<T> to T constructed with args.

Definition at line 82 of file UT_SharedPtr.h.

template<typename T >
std::enable_if_t< UT::detail::is_unbounded_array<T>::value, UT_SharedPtr<T>> UTmakeShared ( size_t  len)
inline

Create UT_SharedPtr<T[]> that points to an array of T[len] buffer

Warning
This is currently disabled until C++20

Definition at line 94 of file UT_SharedPtr.h.

template<typename T >
std::enable_if_t< UT::detail::is_bounded_array<T>::value, UT_SharedPtr<T>> UTmakeShared ( )
inline

Create UT_SharedPtr<T[N]> that points to a T[N] fixed array

Warning
This is currently disabled until C++20

Definition at line 113 of file UT_SharedPtr.h.

template<typename T >
UT_SharedPtr<T> UTmakeSharedArrayPtr ( size_t  len)
inline

Return a UT_SharedPtr<T> that points to an array of T[len] buffer. Only needed until we have proper support in C++20. TODO: Bring back r389476 when macOS has __cpp_lib_shared_ptr_arrays implemented.

Definition at line 57 of file UT_SharedPtr.h.