]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Only use GCC-specific __is_same_as built-in conditionally
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 Oct 2019 10:26:05 +0000 (10:26 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 Oct 2019 10:26:05 +0000 (10:26 +0000)
Clang doesn't support __is_same_as but provides __is_same instead.
Restore the original implementation (pre r276891) when neither of those
built-ins is available.

* include/bits/c++config (_GLIBCXX_BUILTIN_IS_SAME_AS): Define to
one of __is_same_as or __is_same when available.
* include/std/concepts (__detail::__same_as): Use std::is_same_v.
* include/std/type_traits (is_same) [_GLIBCXX_BUILTIN_IS_SAME_AS]:
Use new macro instead of __is_same_as.
(is_same) [!_GLIBCXX_BUILTIN_IS_SAME_AS]: Restore partial
specialization.
(is_same_v) [_GLIBCXX_BUILTIN_IS_SAME_AS]: Use new macro.
(is_same_v) [!_GLIBCXX_BUILTIN_IS_SAME_AS]: Use std::is_same.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@277058 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/c++config
libstdc++-v3/include/std/concepts
libstdc++-v3/include/std/type_traits

index 02b743414dd19265ed98f205c82e5324a63fb80c..c95aa32120b4da6c3932c6fc88f434b47ce5d98c 100644 (file)
@@ -1,3 +1,15 @@
+2019-10-16  Jonathan Wakely  <jwakely@redhat.com>
+
+       * include/bits/c++config (_GLIBCXX_BUILTIN_IS_SAME_AS): Define to
+       one of __is_same_as or __is_same when available.
+       * include/std/concepts (__detail::__same_as): Use std::is_same_v.
+       * include/std/type_traits (is_same) [_GLIBCXX_BUILTIN_IS_SAME_AS]:
+       Use new macro instead of __is_same_as.
+       (is_same) [!_GLIBCXX_BUILTIN_IS_SAME_AS]: Restore partial
+       specialization.
+       (is_same_v) [_GLIBCXX_BUILTIN_IS_SAME_AS]: Use new macro.
+       (is_same_v) [!_GLIBCXX_BUILTIN_IS_SAME_AS]: Use std::is_same.
+
 2019-10-16  François Dumont  <fdumont@gcc.gnu.org>
 
        * src/c++11/debug.cc (print_field): Replace constness_names <unknown>
index c8e099aaadd31ba0961f3167d1b713b982fbdab5..32db60f39e529c549985750e1a98a162348030dc 100644 (file)
@@ -633,6 +633,7 @@ namespace std
 # define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1
 # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
 # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1
+# define _GLIBCXX_BUILTIN_IS_SAME_AS(T, U) __is_same_as(T, U)
 # if __GNUC__ >= 9
 #  define _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED 1
 # endif
@@ -650,6 +651,9 @@ namespace std
 # if __has_builtin(__builtin_is_constant_evaluated)
 #  define _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED 1
 # endif
+# if ! __is_identifier(__is_same)
+#  define _GLIBCXX_BUILTIN_IS_SAME_AS(T, U) __is_same(T, U)
+# endif
 #endif // GCC
 
 // PSTL configuration
index 6b1150a32d21f9c13fb9bd52b8e6e57396d95a7d..6d740eb663c7f8e471b4a1126af3e5e42a7db9c7 100644 (file)
@@ -23,7 +23,7 @@
 // <http://www.gnu.org/licenses/>.
 
 /** @file include/concepts
- *  This is __a Standard C++ Library header.
+ *  This is a Standard C++ Library header.
  *  @ingroup concepts
  */
 
@@ -54,7 +54,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   namespace __detail
   {
     template<typename _Tp, typename _Up>
-      concept __same_as = __is_same_as(_Tp, _Up);
+      concept __same_as = std::is_same_v<_Tp, _Up>;
   } // namespace __detail
 
   /// [concept.same], concept same_as
index 4de5daa9f063af583da3519885852c509cf0814c..8e787a994c34b80303e319f4a7c078ea5c576d36 100644 (file)
@@ -1390,9 +1390,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /// is_same
   template<typename _Tp, typename _Up>
     struct is_same
-    : public integral_constant<bool, __is_same_as(_Tp, _Up)>
+#ifdef _GLIBCXX_BUILTIN_IS_SAME_AS
+    : public integral_constant<bool, _GLIBCXX_BUILTIN_IS_SAME_AS(_Tp, _Up)>
+#else
+    : public false_type
+#endif
     { };
 
+#ifndef _GLIBCXX_BUILTIN_IS_SAME_AS
+  template<typename _Tp>
+    struct is_same<_Tp, _Tp>
+    : public true_type
+    { };
+#endif
+
   /// is_base_of
   template<typename _Base, typename _Derived>
     struct is_base_of
@@ -3154,8 +3165,13 @@ template <typename _Tp>
   inline constexpr size_t rank_v = rank<_Tp>::value;
 template <typename _Tp, unsigned _Idx = 0>
   inline constexpr size_t extent_v = extent<_Tp, _Idx>::value;
+#ifdef _GLIBCXX_BUILTIN_IS_SAME_AS
 template <typename _Tp, typename _Up>
-  inline constexpr bool is_same_v = __is_same_as(_Tp, _Up);
+  inline constexpr bool is_same_v = _GLIBCXX_BUILTIN_IS_SAME_AS(_Tp, _Up);
+#else
+template <typename _Tp, typename _Up>
+  inline constexpr bool is_same_v = std::is_same<_Tp, _Up>::value;
+#endif
 template <typename _Base, typename _Derived>
   inline constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value;
 template <typename _From, typename _To>