diff options
Diffstat (limited to 'source/10-common/TypeTraits.hpp')
-rw-r--r-- | source/10-common/TypeTraits.hpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/source/10-common/TypeTraits.hpp b/source/10-common/TypeTraits.hpp index cca9a1f..73a56f9 100644 --- a/source/10-common/TypeTraits.hpp +++ b/source/10-common/TypeTraits.hpp @@ -1,19 +1,27 @@ #pragma once -template <class T> +#include <cstddef> + +/// This template will be instanciated for each unique type, and the char variable will be ODR-used which gives it an unique address. +template <typename T> +struct TypeIdentifier { + static const char obj = 0; +}; + +template <typename T> struct DefaultDeleter { - void operator()(T* ptr) const { - delete ptr; - } + void operator()(T* ptr) const { + delete ptr; + } }; -template <class> +template <typename> struct RemoveMemberPtrImpl {}; -template <class T, class U> +template <typename T, typename U> struct RemoveMemberPtrImpl<U T::*> { - using Type = U; + using Type = U; }; -template <class T> +template <typename T> using RemoveMemberPtr = typename RemoveMemberPtrImpl<T>::Type; |