types/traits: add the identity type function

This commit is contained in:
Danny Robson 2018-06-22 17:41:36 +10:00
parent a95388b02b
commit 6c0803b6e9

View File

@ -56,6 +56,22 @@ namespace util {
} }
namespace util::types {
///////////////////////////////////////////////////////////////////////////
/// CXX20: An early implementation of std::identity_t and related
/// structures; useful for disabling template argument deduction, and
/// higher order template functions.
template <typename T>
struct identity { using type = T; };
//-------------------------------------------------------------------------
template <typename T>
using identity_t = typename identity<T>::type;
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
template <typename T> struct is_dereferencable : std::false_type { }; template <typename T> struct is_dereferencable : std::false_type { };
template <typename T> struct is_dereferencable<T*> : std::true_type { }; template <typename T> struct is_dereferencable<T*> : std::true_type { };