libstdc++: deprecate is_trivial for C++26 (P3247R2)
This actually implements P3247R2 by deprecating the is_trivial type trait. libstdc++-v3/ChangeLog: * include/std/type_traits: Deprecate is_trivial and is_trivial_v. * include/experimental/type_traits: Suppress the deprecation warning. * testsuite/20_util/is_trivial/requirements/explicit_instantiation.cc: Amend the test to suppress the deprecation warning. * testsuite/20_util/is_trivial/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_trivial/value.cc: Likewise. * testsuite/20_util/variable_templates_for_traits.cc: Likewise. * testsuite/experimental/type_traits/value.cc: Likewise. * testsuite/18_support/max_align_t/requirements/2.cc: Update the test with P3247R2's new wording. Signed-off-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
parent
e663f8f39f
commit
6c41a912f5
8 changed files with 35 additions and 2 deletions
|
@ -121,8 +121,11 @@ template <typename _Tp>
|
|||
constexpr bool is_const_v = is_const<_Tp>::value;
|
||||
template <typename _Tp>
|
||||
constexpr bool is_volatile_v = is_volatile<_Tp>::value;
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
template <typename _Tp>
|
||||
constexpr bool is_trivial_v = is_trivial<_Tp>::value;
|
||||
#pragma GCC diagnostic pop
|
||||
template <typename _Tp>
|
||||
constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value;
|
||||
template <typename _Tp>
|
||||
|
|
|
@ -885,9 +885,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
: public true_type { };
|
||||
#endif
|
||||
|
||||
/// is_trivial
|
||||
/** is_trivial
|
||||
* @deprecated Deprecated in C++26.
|
||||
* Use a combination of one or more more specialized type traits instead,
|
||||
* such as `is_trivially_default_constructible`,
|
||||
* `is_trivially_copy_constructible`, `is_trivially_copy_assignable`,
|
||||
* etc., depending on the exact check(s) needed.
|
||||
*/
|
||||
template<typename _Tp>
|
||||
struct is_trivial
|
||||
struct
|
||||
_GLIBCXX26_DEPRECATED_SUGGEST("is_trivially_default_constructible && is_trivially_copyable")
|
||||
is_trivial
|
||||
: public __bool_constant<__is_trivial(_Tp)>
|
||||
{
|
||||
static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
|
||||
|
@ -3518,6 +3526,7 @@ template <typename _Tp>
|
|||
#endif
|
||||
|
||||
template <typename _Tp>
|
||||
_GLIBCXX26_DEPRECATED_SUGGEST("is_trivially_default_constructible_v && is_trivially_copyable_v")
|
||||
inline constexpr bool is_trivial_v = __is_trivial(_Tp);
|
||||
template <typename _Tp>
|
||||
inline constexpr bool is_trivially_copyable_v = __is_trivially_copyable(_Tp);
|
||||
|
|
|
@ -24,4 +24,8 @@
|
|||
static_assert (std::is_pod<std::max_align_t>::value, "");
|
||||
#endif
|
||||
static_assert (std::is_standard_layout<std::max_align_t>::value, "");
|
||||
static_assert (std::is_trivially_copyable<std::max_align_t>::value, "");
|
||||
static_assert (std::is_trivially_default_constructible<std::max_align_t>::value, "");
|
||||
#if __cplusplus <= 202302L
|
||||
static_assert (std::is_trivial<std::max_align_t>::value, "");
|
||||
#endif
|
||||
|
|
|
@ -25,5 +25,8 @@
|
|||
namespace std
|
||||
{
|
||||
typedef short test_type;
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
template struct is_trivial<test_type>;
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
|
|
|
@ -26,7 +26,10 @@
|
|||
void test01()
|
||||
{
|
||||
// Check for required typedefs
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
typedef std::is_trivial<int> test_type;
|
||||
#pragma GCC diagnostic pop
|
||||
typedef test_type::value_type value_type;
|
||||
typedef test_type::type type;
|
||||
typedef test_type::type::value_type type_value_type;
|
||||
|
|
|
@ -27,9 +27,12 @@ void test01()
|
|||
using std::is_trivial;
|
||||
using namespace __gnu_test;
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
static_assert(test_category<is_trivial, TType>(true), "");
|
||||
static_assert(test_category<is_trivial, PODType>(true), "");
|
||||
|
||||
static_assert(test_category<is_trivial, NType>(false), "");
|
||||
static_assert(test_category<is_trivial, SLType>(false), "");
|
||||
#pragma GCC diagnostic pop
|
||||
}
|
||||
|
|
|
@ -129,8 +129,12 @@ private:
|
|||
int i2;
|
||||
};
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
// Deprecated in C++26
|
||||
static_assert(is_trivial_v<int> && is_trivial<int>::value, "");
|
||||
static_assert(!is_trivial_v<NType> && !is_trivial<NType>::value, "");
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
static_assert(is_trivially_copyable_v<int>
|
||||
&& is_trivially_copyable<int>::value, "");
|
||||
|
|
|
@ -196,8 +196,12 @@ private:
|
|||
int i2;
|
||||
};
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
// Deprecated in C++26
|
||||
static_assert(is_trivial_v<int> && is_trivial<int>::value, "");
|
||||
static_assert(!is_trivial_v<NType> && !is_trivial<NType>::value, "");
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
static_assert(is_trivially_copyable_v<int>
|
||||
&& is_trivially_copyable<int>::value, "");
|
||||
|
|
Loading…
Add table
Reference in a new issue