diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2024-07-29 19:23:54 +0200 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2024-10-05 14:34:29 -0400 |
commit | 9fc5b8f956948e069d9b69ceed7316940bc798e2 (patch) | |
tree | c319b16f54b9bda395cca22e146b778ef76fd393 /libstdc++-v3/include | |
parent | 7c0d1e9f2a2f1d41d9eb755c36c871d92638c4b7 (diff) | |
download | gcc-9fc5b8f956948e069d9b69ceed7316940bc798e2.zip gcc-9fc5b8f956948e069d9b69ceed7316940bc798e2.tar.gz gcc-9fc5b8f956948e069d9b69ceed7316940bc798e2.tar.bz2 |
libstdc++: add std::is_virtual_base_of
Added by P2985R0 for C++26. This simply exposes the compiler
builtin, and adds the feature-testing macro.
libstdc++-v3/ChangeLog:
* include/bits/version.def: Added the feature-testing macro.
* include/bits/version.h: Regenerated.
* include/std/type_traits: Add support for
std::is_virtual_base_of and std::is_virtual_base_of_v,
implemented in terms of the compiler builtin.
* testsuite/20_util/is_virtual_base_of/value.cc: New test.
Signed-off-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r-- | libstdc++-v3/include/bits/version.def | 9 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/version.h | 10 | ||||
-rw-r--r-- | libstdc++-v3/include/std/type_traits | 14 |
3 files changed, 33 insertions, 0 deletions
diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def index f2e2817..477651f 100644 --- a/libstdc++-v3/include/bits/version.def +++ b/libstdc++-v3/include/bits/version.def @@ -1808,6 +1808,15 @@ ftms = { }; ftms = { + name = is_virtual_base_of; + values = { + v = 202406; + cxxmin = 26; + extra_cond = "__has_builtin(__builtin_is_virtual_base_of)"; + }; +}; + +ftms = { name = ranges_concat; values = { v = 202403; diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h index dcd93fd..342ee6b 100644 --- a/libstdc++-v3/include/bits/version.h +++ b/libstdc++-v3/include/bits/version.h @@ -2000,6 +2000,16 @@ #endif /* !defined(__cpp_lib_fstream_native_handle) && defined(__glibcxx_want_fstream_native_handle) */ #undef __glibcxx_want_fstream_native_handle +#if !defined(__cpp_lib_is_virtual_base_of) +# if (__cplusplus > 202302L) && (__has_builtin(__builtin_is_virtual_base_of)) +# define __glibcxx_is_virtual_base_of 202406L +# if defined(__glibcxx_want_all) || defined(__glibcxx_want_is_virtual_base_of) +# define __cpp_lib_is_virtual_base_of 202406L +# endif +# endif +#endif /* !defined(__cpp_lib_is_virtual_base_of) && defined(__glibcxx_want_is_virtual_base_of) */ +#undef __glibcxx_want_is_virtual_base_of + #if !defined(__cpp_lib_ranges_concat) # if (__cplusplus > 202302L) # define __glibcxx_ranges_concat 202403L diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 6e67780..17ae2c4 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -53,6 +53,7 @@ #define __glibcxx_want_is_pointer_interconvertible #define __glibcxx_want_is_scoped_enum #define __glibcxx_want_is_swappable +#define __glibcxx_want_is_virtual_base_of #define __glibcxx_want_logical_traits #define __glibcxx_want_reference_from_temporary #define __glibcxx_want_remove_cvref @@ -1541,6 +1542,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __bool_constant<__is_base_of(_Base, _Derived)> { }; +#ifdef __cpp_lib_is_virtual_base_of // C++ >= 26 + /// is_virtual_base_of + /// @since C++26 + template<typename _Base, typename _Derived> + struct is_virtual_base_of + : public bool_constant<__builtin_is_virtual_base_of(_Base, _Derived)> + { }; +#endif + #if _GLIBCXX_USE_BUILTIN_TRAIT(__is_convertible) template<typename _From, typename _To> struct is_convertible @@ -3636,6 +3646,10 @@ template <typename _Tp> #endif template <typename _Base, typename _Derived> inline constexpr bool is_base_of_v = __is_base_of(_Base, _Derived); +#ifdef __cpp_lib_is_virtual_base_of // C++ >= 26 +template <typename _Base, typename _Derived> + inline constexpr bool is_virtual_base_of_v = __builtin_is_virtual_base_of(_Base, _Derived); +#endif #if _GLIBCXX_USE_BUILTIN_TRAIT(__is_convertible) template <typename _From, typename _To> inline constexpr bool is_convertible_v = __is_convertible(_From, _To); |