Difference between revisions of "cpp/memory/owner less void"
From cppreference.com
m (langlinks) |
m (→Notes: reorder.) |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{cpp/title|owner_less}} | {{cpp/title|owner_less}} | ||
{{cpp/memory/navbar}} | {{cpp/memory/navbar}} | ||
− | {{ddcl | header = memory | since=c++17 | 1= | + | {{ddcl|header=memory|since=c++17|1= |
template<> | template<> | ||
struct owner_less<void>; | struct owner_less<void>; | ||
}} | }} | ||
− | {{c|std::owner_less<>}} is a specialization of {{lc|std::owner_less}} with parameter types deduced. | + | {{c/core|std::owner_less<void>}} is a specialization of {{lc|std::owner_less}} with parameter types deduced. |
− | === | + | ===Nested types=== |
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc hitem | | + | {{dsc hitem|Nested type|Definition}} |
− | {{dsc | {{tt|is_transparent}} | / | + | {{dsc|{{tt|is_transparent}}|[[cpp/utility/functional#Transparent function objects|unspecified]]}} |
{{dsc end}} | {{dsc end}} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
===Member functions=== | ===Member functions=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc fun | cpp/memory/owner_less_void | title=operator() | inlinemem=true | compares its arguments using owner-based semantics}} | + | {{dsc fun|cpp/memory/owner_less_void|title=operator()|inlinemem=true|compares its arguments using owner-based semantics}} |
{{dsc end}} | {{dsc end}} | ||
− | {{member | {{small|std::owner_less<void>::}}operator() | | + | {{member|{{small|std::owner_less<void>::}}operator()| |
{{dcl begin}} | {{dcl begin}} | ||
− | {{dcl | since=c++17 | | + | {{dcl|since=c++17| |
− | template<class T, class U> | + | template< class T, class U > |
− | bool operator()( const std::shared_ptr<T>& lhs, | + | bool operator()( const std::shared_ptr<T>& lhs, |
const std::shared_ptr<U>& rhs ) const noexcept; | const std::shared_ptr<U>& rhs ) const noexcept; | ||
}} | }} | ||
− | {{dcl | since=c++17 | | + | {{dcl|since=c++17| |
− | template<class T, class U> | + | template< class T, class U > |
− | bool operator()( const std::shared_ptr<T>& lhs, | + | bool operator()( const std::shared_ptr<T>& lhs, |
const std::weak_ptr<U>& rhs ) const noexcept; | const std::weak_ptr<U>& rhs ) const noexcept; | ||
}} | }} | ||
− | {{dcl | since=c++17 | | + | {{dcl|since=c++17| |
− | template<class T, class U> | + | template< class T, class U > |
− | bool operator()( const std::weak_ptr<T>& lhs, | + | bool operator()( const std::weak_ptr<T>& lhs, |
const std::shared_ptr<U>& rhs ) const noexcept; | const std::shared_ptr<U>& rhs ) const noexcept; | ||
}} | }} | ||
− | {{dcl | since=c++17 | | + | {{dcl|since=c++17| |
− | template<class T, class U> | + | template< class T, class U > |
− | bool operator()( const std::weak_ptr<T>& lhs, | + | bool operator()( const std::weak_ptr<T>& lhs, |
const std::weak_ptr<U>& rhs ) const noexcept; | const std::weak_ptr<U>& rhs ) const noexcept; | ||
}} | }} | ||
{{dcl end}} | {{dcl end}} | ||
− | Compares {{ | + | Compares {{c|lhs}} and {{c|rhs}} using owner-based semantics. Effectively calls {{c|lhs.owner_before(rhs)}}. |
The ordering is strict weak ordering relation. | The ordering is strict weak ordering relation. | ||
− | {{ | + | {{c|lhs}} and {{c|rhs}} are equivalent only if they are both empty or share ownership. |
===Parameters=== | ===Parameters=== | ||
{{par begin}} | {{par begin}} | ||
− | {{par | lhs, rhs | shared-ownership pointers to compare}} | + | {{par|lhs, rhs|shared-ownership pointers to compare}} |
{{par end}} | {{par end}} | ||
===Return value=== | ===Return value=== | ||
− | {{c|true}} if {{ | + | {{c|true}} if {{c|lhs}} is ''less than'' {{c|rhs}} as determined by the owner-based ordering. |
− | + | ||
}} | }} | ||
+ | |||
+ | ===Notes=== | ||
+ | {{feature test macro|__cpp_lib_transparent_operators|Transparent {{lc|std::owner_less}} ({{c/core|std::owner_less<void>}})|value=201510L|std=C++17}} | ||
===See also=== | ===See also=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc inc | cpp/memory/shared_ptr/dsc owner_before}} | + | {{dsc inc|cpp/memory/shared_ptr/dsc owner_before}} |
− | {{dsc inc | cpp/memory/weak_ptr/dsc owner_before}} | + | {{dsc inc|cpp/memory/weak_ptr/dsc owner_before}} |
{{dsc end}} | {{dsc end}} | ||
{{langlinks|de|es|fr|it|ja|pt|ru|zh}} | {{langlinks|de|es|fr|it|ja|pt|ru|zh}} |
Latest revision as of 04:50, 3 January 2024
Defined in header <memory>
|
||
template<> struct owner_less<void>; |
(since C++17) | |
std::owner_less<void> is a specialization of std::owner_less with parameter types deduced.
Contents |
[edit] Nested types
Nested type | Definition |
is_transparent
|
unspecified |
[edit] Member functions
operator() |
compares its arguments using owner-based semantics (function) |
std::owner_less<void>::operator()
template< class T, class U > bool operator()( const std::shared_ptr<T>& lhs, |
(since C++17) | |
template< class T, class U > bool operator()( const std::shared_ptr<T>& lhs, |
(since C++17) | |
template< class T, class U > bool operator()( const std::weak_ptr<T>& lhs, |
(since C++17) | |
template< class T, class U > bool operator()( const std::weak_ptr<T>& lhs, |
(since C++17) | |
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.
[edit] Notes
Feature-test macro | Value | Std | Feature |
---|---|---|---|
__cpp_lib_transparent_operators |
201510L | (C++17) | Transparent std::owner_less (std::owner_less<void>) |
[edit] See also
provides owner-based ordering of shared pointers (public member function of std::shared_ptr<T> )
| |
provides owner-based ordering of weak pointers (public member function of std::weak_ptr<T> )
|