diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2019-10-16 11:26:05 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2019-10-16 11:26:05 +0100 |
commit | 44af818f006a046ffadcfe39e7d475956ae55317 (patch) | |
tree | cb601b79c1cdca52fd0dfccc8addf287e5b99c97 /libstdc++-v3 | |
parent | bf78ed91a445d188e4368adc30dd5c32d973ed6e (diff) | |
download | gcc-44af818f006a046ffadcfe39e7d475956ae55317.zip gcc-44af818f006a046ffadcfe39e7d475956ae55317.tar.gz gcc-44af818f006a046ffadcfe39e7d475956ae55317.tar.bz2 |
Only use GCC-specific __is_same_as built-in conditionally
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.
From-SVN: r277058
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 12 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/c++config | 4 | ||||
-rw-r--r-- | libstdc++-v3/include/std/concepts | 4 | ||||
-rw-r--r-- | libstdc++-v3/include/std/type_traits | 20 |
4 files changed, 36 insertions, 4 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 02b7434..c95aa32 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -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> diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index c8e099a..32db60f 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -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 diff --git a/libstdc++-v3/include/std/concepts b/libstdc++-v3/include/std/concepts index 6b1150a..6d740eb 100644 --- a/libstdc++-v3/include/std/concepts +++ b/libstdc++-v3/include/std/concepts @@ -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 diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 4de5daa..8e787a9 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -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> |