mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-02 11:49:55 -06:00
STL: extend type_traits to deal with member pointers
This commit is contained in:
@@ -249,6 +249,14 @@ These are:
|
||||
* ``cm::is_unique_ptr``:
|
||||
Checks if a type is a ``std::unique_ptr`` type.
|
||||
|
||||
* ``cm::remove_member_pointer``
|
||||
Produces the underlying type of a member-pointer type, ie, given ``T C::*``,
|
||||
returns ``T``.
|
||||
|
||||
* ``cm::member_pointer_class``
|
||||
Produces the class associated with a member-pointer type, ie, given
|
||||
``T C::*``, returns ``C``.
|
||||
|
||||
CMake assumes the compiler supports ``#pragma once``. Use this for all
|
||||
hand-written header files.
|
||||
|
||||
|
||||
@@ -82,4 +82,30 @@ using is_sequence_container =
|
||||
!cm::is_associative_container<T>::value &&
|
||||
!cm::is_unordered_associative_container<T>::value>;
|
||||
|
||||
template <typename T>
|
||||
struct remove_member_pointer
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
template <typename T, typename U>
|
||||
struct remove_member_pointer<T U::*>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
template <typename T>
|
||||
using remove_member_pointer_t = typename remove_member_pointer<T>::type;
|
||||
|
||||
template <typename T>
|
||||
struct member_pointer_class
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
template <typename T, typename U>
|
||||
struct member_pointer_class<U T::*>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
template <typename T>
|
||||
using member_pointer_class_t = typename member_pointer_class<T>::type;
|
||||
|
||||
} // namespace cm
|
||||
|
||||
Reference in New Issue
Block a user