Title
The less-than operator for shared pointers could do more
Status
c++17
Section
[util.smartptr.shared.cmp]
Submitter
United States

Created on 2017-02-03.00:00:00 last changed 81 months ago

Messages

Date: 2017-03-03.22:08:49

Proposed resolution:

This wording is relative to N4640.

  1. Change [util.smartptr.shared.cmp] as depicted:

    template<class T, class U>
    bool operator<(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
    

    -2- Returns: less<V>()(a.get(), b.get()), where V is the composite pointer type (Clause 5) of shared_ptr<T>::element_type* and shared_ptr<U>::element_type*.

Date: 2017-03-03.22:08:49

[ Kona 2017-03-02 ]

Accepted as Immediate to resolve NB comment.

Date: 2017-03-15.00:00:00

[ 2017-03-02, Kona, STL comments and provides wording ]

We talked about this in LWG, and I talked to Alisdair. The status quo is already maximally general (operator less-than in Core always forms a composite pointer type), but we can use diamond-less to significantly simplify the specification. (We can't use less-than directly, due to the total ordering issue, which diamond-less was recently "upgraded" to handle.)

Date: 2017-02-03.00:00:00
Addresses US 135

The less-than operator for shared pointers compares only those combinations that can form a composite pointer type. With the C++17 wording for the diamond functor, less<>, we should be able to support comparison of a wider range of shared pointers, such that less<>::operator(shared_ptr<A>, shared_ptr<B>) is consistent with less<>::operator(A *, B *).

Proposed change: Replace less<V> with just less<>, and drop the reference to composite pointer types.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2017-03-05 23:46:08adminsetstatus: immediate -> wp
2017-03-03 22:08:49adminsetmessages: + msg9062
2017-03-03 22:08:49adminsetstatus: new -> immediate
2017-03-02 17:01:50adminsetmessages: + msg9036
2017-03-02 17:01:50adminsetmessages: + msg9035
2017-02-03 00:00:00admincreate