Created on 2021-04-20.00:00:00 last changed 12 months ago
Proposed resolution:
This wording is relative to N4885.
Modify [format.arg] as indicated:
template<class traits> explicit basic_format_arg(basic_string_view<char_type, traits> s) noexcept;-9- Effects: Initializes value with
sbasic_string_view<char_type>(s.data(), s.size()).
[ 2021-06-07 Approved at June 2021 virtual plenary. Status changed: Voting → WP. ]
[ 2021-05-10; Reflector poll ]
Set status to Tentatively Ready after eight votes in favour during reflector poll.
basic_format_arg has a constructor that accepts a basic_string_view of an appropriate character type, with any traits type. The constructor is specified in [format.arg] as:
template<class traits> explicit basic_format_arg(basic_string_view<char_type, traits> s) noexcept;-9- Effects: Initializes value with s.
Recall that value is a variant<monostate, bool, char_type, int, unsigned int, long long int, unsigned long long int, float, double, long double, const char_type*, basic_string_view<char_type>, const void*, handle> as specified earlier in the subclause. Since basic_string_view<meow, woof> cannot be initialized with an lvalue basic_string_view<meow, quack> — and certainly none of the other alternative types can be initialized by such an lvalue — the effects of this constructor are ill-formed when traits is not std::char_traits<char_type>.
The basic_string constructor deals with this same issue by ignoring the deduced traits type when initializing value's basic_string_view member:template<class traits, class Allocator> explicit basic_format_arg( const basic_string<char_type, traits, Allocator>& s) noexcept;-10- Effects: Initializes value with basic_string_view<char_type>(s.data(), s.size()).
which immediately begs the question of "why doesn't the basic_string_view constructor do the same?"
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-11-22 15:47:43 | admin | set | status: wp -> c++23 |
2021-06-07 16:58:04 | admin | set | messages: + msg11907 |
2021-06-07 16:58:04 | admin | set | status: voting -> wp |
2021-05-26 21:11:22 | admin | set | status: ready -> voting |
2021-05-10 16:28:00 | admin | set | messages: + msg11794 |
2021-05-10 16:28:00 | admin | set | status: new -> ready |
2021-04-24 15:51:44 | admin | set | status: ready -> new |
2021-04-24 15:45:29 | admin | set | messages: + msg11779 |
2021-04-20 00:00:00 | admin | create |