In preparation for the deprecation of is_trivial (P3247R2), stop using
it from std::string_view. Also, add the same detection to std::string
(described in [strings.general]/2).
libstdc++-v3/ChangeLog:
* include/bits/basic_string.h: Add a static_assert on the
char-like type.
* include/std/string_view: Port away from is_trivial.
Signed-off-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
class basic_string
{
#if __cplusplus >= 202002L
+ static_assert(is_trivially_copyable_v<_CharT>
+ && is_trivially_default_constructible_v<_CharT>
+ && is_standard_layout_v<_CharT>);
static_assert(is_same_v<_CharT, typename _Traits::char_type>);
static_assert(is_same_v<_CharT, typename _Alloc::value_type>);
using _Char_alloc_type = _Alloc;
class basic_string_view
{
static_assert(!is_array_v<_CharT>);
- static_assert(is_trivial_v<_CharT> && is_standard_layout_v<_CharT>);
+ static_assert(is_trivially_copyable_v<_CharT>
+ && is_trivially_default_constructible_v<_CharT>
+ && is_standard_layout_v<_CharT>);
static_assert(is_same_v<_CharT, typename _Traits::char_type>);
public: