std::owner_less
Min standard notice:
Header: <memory>
This function object provides owner-based (as opposed to value-based) mixed-type ordering of both std::weak_ptr and std::shared_ptr. The order is such that two smart pointers compare equivalent only if they are both empty or if they share ownership, even if the values of the raw pointers obtained by get() are different (e.g. because they point at different subobjects within the same object).
# Declarations
template< class T >
struct owner_less; /* undefined */
(since C++11) (until C++17)
template< class T = void >
struct owner_less; /* undefined */
(since C++17)
template< class T >
struct owner_less<std::shared_ptr<T>>;
(since C++11)
template< class T >
struct owner_less<std::weak_ptr<T>>;
(since C++11)
template<>
struct owner_less<void>;
(since C++17)
# Parameters
lhs, rhs: shared-ownership pointers to compare
# Return value
true if lhs is less than rhs as determined by the owner-based ordering, false otherwise.
# Defect reports
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 2873 | C++11 | operator() was not required to be noexcept | required to be noexcept |