A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/language/../error/error_code/../../../cpp/memory/owner_less.html below:

std::owner_less - cppreference.com

(1)

template< class T >
struct owner_less; /* undefined */

(since C++11)
(until C++17)

template< class T = void >
struct owner_less; /* undefined */

(since C++17) (2) (since C++11) (3) (since C++11)

template<>
struct owner_less<void>;

(4) (since C++17)

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).

4) The void specialization deduces the parameter types from the arguments.

The default operator< is not defined for weak pointers, and may wrongly consider two shared pointers for the same object non-equivalent (see std::shared_ptr::owner_before).

Specializations

The standard library provides a specialization of std::owner_less when T is not specified. In this case, the parameter types are deduced from the arguments (each of which must still be either a std::shared_ptr or a std::weak_ptr).

function object providing mixed-type owner-based ordering of shared and weak pointers, regardless of the type of the pointee
(class template specialization) [edit] (since C++17) Nested types (until C++20) [edit] Member functions compares its arguments using owner-based semantics
(function) std::owner_less::operator()

Compares lhs and rhs using owner-based semantics. Effectively calls lhs.owner_before(rhs).

The ordering is strict weak ordering relation.

lhs and rhs are equivalent only if they are both empty or share ownership.

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.

[edit] Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior LWG 2873 C++11 operator() was not required to be noexcept required to be noexcept [edit] See also provides owner-based ordering of shared pointers
(public member function of std::shared_ptr<T>) [edit] provides owner-based ordering of weak pointers
(public member function of std::weak_ptr<T>) [edit]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4