This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++23 status.
single_view
's in place constructor should be explicitSection: 25.6.3.2 [range.single.view] Status: C++23 Submitter: Tim Song Opened: 2020-04-07 Last modified: 2023-11-22
Priority: 0
View all other issues in [range.single.view].
View all issues with C++23 status.
Discussion:
The in_place_t
constructor template of single_view
is not explicit:
template<class... Args> requires constructible_from<T, Args...> constexpr single_view(in_place_t, Args&&... args);
so it defines an implicit conversion from std::in_place_t
to
single_view<T>
whenever constructible_from<T>
is modeled,
which seems unlikely to be the intent.
[2020-04-18 Issue Prioritization]
Status set to Tentatively Ready after six positive votes on the reflector.
[2020-11-09 Approved In November virtual meeting. Status changed: Tentatively Ready → WP.]
Proposed resolution:
This wording is relative to N4861.
Modify 25.6.3.2 [range.single.view] as indicated:
[…]namespace std::ranges { template<copy_constructible T> requires is_object_v<T> class single_view : public view_interface<single_view<T>> { […] public: […] template<class... Args> requires constructible_from<T, Args...> constexpr explicit single_view(in_place_t, Args&&... args); […] }; }template<class... Args> constexpr explicit single_view(in_place_t, Args&&... args);-3- Effects: Initializes
value_
as if byvalue_{in_place, std::forward<Args>(args)...}
.