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.
operator<=>(const unique_ptr<T, D>&, nullptr_t)
can't get no satisfactionSection: 20.3.1.6 [unique.ptr.special] Status: C++23 Submitter: Jonathan Wakely Opened: 2020-04-09 Last modified: 2023-11-22
Priority: 0
View all other issues in [unique.ptr.special].
View all issues with C++23 status.
Discussion:
The constraint for operator<=>(const unique_ptr<T, D>&, nullptr_t)
cannot be satisfied, because std::three_way_comparable<nullptr_t>
is false
,
because nullptr <=> nullptr
is ill-formed.
x.get()
to pointer(nullptr)
instead of to nullptr
directly.
[2020-04-14; Replacing the functional cast by a static_cast
as result of reflector discussion]
[2020-04-18 Issue Prioritization]
Status set to Tentatively Ready after seven 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 20.2.2 [memory.syn] as indicated:
[…] template<class T, class D> bool operator>=(nullptr_t, const unique_ptr<T, D>& y); template<class T, class D> requires three_way_comparable_with<typename unique_ptr<T, D>::pointer, nullptr_t> compare_three_way_result_t<typename unique_ptr<T, D>::pointer, nullptr_t> operator<=>(const unique_ptr<T, D>& x, nullptr_t); […]
Modify 20.3.1.6 [unique.ptr.special] as indicated:
template<class T, class D> requires three_way_comparable_with<typename unique_ptr<T, D>::pointer, nullptr_t> compare_three_way_result_t<typename unique_ptr<T, D>::pointer, nullptr_t> operator<=>(const unique_ptr<T, D>& x, nullptr_t);-18- Returns:
compare_three_way()(x.get(), static_cast<typename unique_ptr<T, D>::pointer>(nullptr))
.