From af39a9a47f1f6c6ce03db44f776283359f1f8949 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Fri, 17 Apr 2020 15:33:37 +0300 Subject: [PATCH] Allow non deletable/destructible types. --- sqrat/sqrat/sqratUtil.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/sqrat/sqrat/sqratUtil.h b/sqrat/sqrat/sqratUtil.h index fe8ddfab..518ddee5 100644 --- a/sqrat/sqrat/sqratUtil.h +++ b/sqrat/sqrat/sqratUtil.h @@ -596,6 +596,19 @@ template < class T > struct SqDefaultDelete< T[] > { template < class T, unsigned N > struct SqDefaultDelete< T[N] >; // ==================================================================================================================== ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// Primary template of `SqDefaultNoDelete`. Will do absolutely nothing. +/// +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +template < class T > struct SqDefaultNoDelete { + // The type given via template parameter. + using ValueType = T; + // Default constructor. + constexpr SqDefaultNoDelete() noexcept = default; + // Dummy function call operator. + void operator () (T * SQ_UNUSED_ARG(p)) const { } +}; +// ==================================================================================================================== +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Primary template of `SqDefaultDestructor`. Will only invoke the instance destructor and not free the associated memory. /// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -632,6 +645,19 @@ template < class T > struct SqDefaultDestructor< T[] > { // Omit specialization for array objects with a compile time length. template < class T, unsigned N > struct SqDefaultDestructor< T[N] >; +// ==================================================================================================================== +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// Primary template of `SqDefaultNoDestructor`. Will do absolutely nothing. +/// +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +template < class T > struct SqDefaultNoDestructor { + // The type given via template parameter. + using ValueType = T; + // Default constructor. + constexpr SqDefaultNoDestructor() noexcept = default; + // Dummy function call operator. + void operator () (T * SQ_UNUSED_ARG(p)) const { } +}; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Used internally to store the counters of managed pointers. ///