Created on 2025-07-12.00:00:00 last changed 6 days ago
Proposed resolution:
This wording is relative to N5008.
Modify [bitset.cons] as indicated:
template<class charT> constexpr explicit bitset( const charT* str, typename basic_string_view<charT>::size_type n = basic_string_view<charT>::npos, charT zero = charT(’0’), charT one = charT(’1’));
-?- Constraints:
is_array_v<charT>
is `false`,is_trivially_copyable_v<charT>
is `true`,is_standard_layout_v<charT>
is `true`, andis_trivially_default_constructible_v<charT>
is `true`.-8- Effects: As if by:
bitset(n == basic_string_view<charT>::npos ? basic_string_view<charT>(str) : basic_string_view<charT>(str, n), 0, n, zero, one)
This code might be ill-formed, with an error outside the immediate context that users cannot prevent:
#include <bitset> struct NonTrivial { ~NonTrivial() { } }; static_assert( ! std::is_constructible_v<std::bitset<1>, NonTrivial*> );
The problem is that the `bitset(const CharT*)` constructor tries to instantiate
basic_string_view<NonTrivial>
to find its `size_type`,
and that instantiation might ill-formed, e.g. if `std::basic_string_view` or
`std::char_traits` has a static assert enforcing the requirement for their
character type to be sufficiently char-like. [strings.general]
defines a char-like type as "any non-array trivially copyable standard-layout
([basic.types.general]) type `T`
where is_trivially_default_constructible_v<T>
is `true`."
History | |||
---|---|---|---|
Date | User | Action | Args |
2025-07-12 11:21:41 | admin | set | messages: + msg14895 |
2025-07-12 00:00:00 | admin | create |