[libcxx-commits] [libcxx] [libc++] Merge is_member{, _object, _function}_pointer.h (PR #98727)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jul 13 01:44:12 PDT 2024


https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/98727

The implementations for these traits have been simplified quite a bit, since we have builtins available for them now.


>From f309428f0057c77ce90ed08bcd8c3917f5a84d4a Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Tue, 21 May 2024 18:24:59 +0200
Subject: [PATCH] [libc++] Merge is_member{,_object,_function}_pointer.h

---
 libcxx/include/CMakeLists.txt                 |  2 --
 libcxx/include/__type_traits/invoke.h         |  3 +-
 .../is_member_function_pointer.h              | 31 -------------------
 .../__type_traits/is_member_object_pointer.h  | 31 -------------------
 .../include/__type_traits/is_member_pointer.h | 12 +++++++
 libcxx/include/module.modulemap               |  2 --
 libcxx/include/type_traits                    |  2 --
 7 files changed, 13 insertions(+), 70 deletions(-)
 delete mode 100644 libcxx/include/__type_traits/is_member_function_pointer.h
 delete mode 100644 libcxx/include/__type_traits/is_member_object_pointer.h

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 07dd25604a9c7..cd64fe91449c2 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -777,8 +777,6 @@ set(files
   __type_traits/is_implicitly_default_constructible.h
   __type_traits/is_integral.h
   __type_traits/is_literal_type.h
-  __type_traits/is_member_function_pointer.h
-  __type_traits/is_member_object_pointer.h
   __type_traits/is_member_pointer.h
   __type_traits/is_nothrow_assignable.h
   __type_traits/is_nothrow_constructible.h
diff --git a/libcxx/include/__type_traits/invoke.h b/libcxx/include/__type_traits/invoke.h
index a0281f5b20064..71db32ae6a3ce 100644
--- a/libcxx/include/__type_traits/invoke.h
+++ b/libcxx/include/__type_traits/invoke.h
@@ -17,8 +17,7 @@
 #include <__type_traits/integral_constant.h>
 #include <__type_traits/is_base_of.h>
 #include <__type_traits/is_core_convertible.h>
-#include <__type_traits/is_member_function_pointer.h>
-#include <__type_traits/is_member_object_pointer.h>
+#include <__type_traits/is_member_pointer.h>
 #include <__type_traits/is_reference_wrapper.h>
 #include <__type_traits/is_same.h>
 #include <__type_traits/is_void.h>
diff --git a/libcxx/include/__type_traits/is_member_function_pointer.h b/libcxx/include/__type_traits/is_member_function_pointer.h
deleted file mode 100644
index 037d5ca04ab0b..0000000000000
--- a/libcxx/include/__type_traits/is_member_function_pointer.h
+++ /dev/null
@@ -1,31 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H
-#define _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H
-
-#include <__config>
-#include <__type_traits/integral_constant.h>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#  pragma GCC system_header
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer : _BoolConstant<__is_member_function_pointer(_Tp)> {};
-
-#  if _LIBCPP_STD_VER >= 17
-template <class _Tp>
-inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp);
-#  endif
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H
diff --git a/libcxx/include/__type_traits/is_member_object_pointer.h b/libcxx/include/__type_traits/is_member_object_pointer.h
deleted file mode 100644
index 555794bfe0387..0000000000000
--- a/libcxx/include/__type_traits/is_member_object_pointer.h
+++ /dev/null
@@ -1,31 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP___TYPE_TRAITS_IS_MEMBER_OBJECT_POINTER_H
-#define _LIBCPP___TYPE_TRAITS_IS_MEMBER_OBJECT_POINTER_H
-
-#include <__config>
-#include <__type_traits/integral_constant.h>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#  pragma GCC system_header
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer : _BoolConstant<__is_member_object_pointer(_Tp)> {};
-
-#  if _LIBCPP_STD_VER >= 17
-template <class _Tp>
-inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp);
-#  endif
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H
diff --git a/libcxx/include/__type_traits/is_member_pointer.h b/libcxx/include/__type_traits/is_member_pointer.h
index 149634fde7584..cc125e318cf91 100644
--- a/libcxx/include/__type_traits/is_member_pointer.h
+++ b/libcxx/include/__type_traits/is_member_pointer.h
@@ -21,9 +21,21 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> {};
 
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer : _BoolConstant<__is_member_object_pointer(_Tp)> {};
+
+template <class _Tp>
+struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer : _BoolConstant<__is_member_function_pointer(_Tp)> {};
+
 #  if _LIBCPP_STD_VER >= 17
 template <class _Tp>
 inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp);
+
+template <class _Tp>
+inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp);
+
+template <class _Tp>
+inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp);
 #  endif
 
 _LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index 4ad506781c489..f4aaa14c1c2ee 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -1962,8 +1962,6 @@ module std_private_type_traits_is_fundamental                            [system
 module std_private_type_traits_is_implicitly_default_constructible       [system] { header "__type_traits/is_implicitly_default_constructible.h" }
 module std_private_type_traits_is_integral                               [system] { header "__type_traits/is_integral.h" }
 module std_private_type_traits_is_literal_type                           [system] { header "__type_traits/is_literal_type.h" }
-module std_private_type_traits_is_member_function_pointer                [system] { header "__type_traits/is_member_function_pointer.h" }
-module std_private_type_traits_is_member_object_pointer                  [system] { header "__type_traits/is_member_object_pointer.h" }
 module std_private_type_traits_is_member_pointer                         [system] { header "__type_traits/is_member_pointer.h" }
 module std_private_type_traits_is_nothrow_assignable                     [system] { header "__type_traits/is_nothrow_assignable.h" }
 module std_private_type_traits_is_nothrow_constructible                  [system] {
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index aee9fcf4137f3..a77ddadafb681 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -467,8 +467,6 @@ namespace std
 #include <__type_traits/is_implicitly_default_constructible.h>
 #include <__type_traits/is_integral.h>
 #include <__type_traits/is_literal_type.h>
-#include <__type_traits/is_member_function_pointer.h>
-#include <__type_traits/is_member_object_pointer.h>
 #include <__type_traits/is_member_pointer.h>
 #include <__type_traits/is_nothrow_assignable.h>
 #include <__type_traits/is_nothrow_constructible.h>



More information about the libcxx-commits mailing list