std::owner_less

来自cppreference.com
< cpp‎ | memory
 
 
工具库
语言支持
类型支持(基本类型、RTTI)
库功能特性测试宏 (C++20)
动态内存管理
程序工具
协程支持 (C++20)
变参数函数
调试支持
(C++26)
三路比较
(C++20)
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
通用工具
日期和时间
函数对象
格式化库 (C++20)
(C++11)
关系运算符 (C++20 中弃用)
整数比较函数
(C++20)(C++20)(C++20)   
(C++20)
交换类型运算
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
常用词汇类型
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)
初等字符串转换
(C++17)
(C++17)

 
动态内存管理
未初始化内存算法
受约束的未初始化内存算法
分配器
垃圾收集器支持
(C++11)(C++23 前)
(C++11)(C++23 前)
(C++11)(C++23 前)
(C++11)(C++23 前)
(C++11)(C++23 前)
(C++11)(C++23 前)



 
在标头 <memory> 定义
template<>
struct owner_less<void>;
(C++17 起)

std::owner_less<void> 是拥有待推导形参类型的 std::owner_less 特化。

嵌套类型

嵌套类型 定义
is_transparent 未指定

成员函数

operator()
用基于所有者的语义比较其实参
(函数)

std::owner_less<void>::operator()

template< class T, class U >

bool operator()( const std::shared_ptr<T>& lhs,

                 const std::shared_ptr<U>& rhs ) const noexcept;
(C++17 起)
template< class T, class U >

bool operator()( const std::shared_ptr<T>& lhs,

                 const std::weak_ptr<U>& rhs ) const noexcept;
(C++17 起)
template< class T, class U >

bool operator()( const std::weak_ptr<T>& lhs,

                 const std::shared_ptr<U>& rhs ) const noexcept;
(C++17 起)
template< class T, class U >

bool operator()( const std::weak_ptr<T>& lhs,

                 const std::weak_ptr<U>& rhs ) const noexcept;
(C++17 起)

用基于所有者的语义比较 lhsrhs。相当于调用 lhs.owner_before(rhs)

顺序是严格弱序关系。

仅当 lhsrhs 都为空或共享所有权时才等价。

参数

lhs, rhs - 要比较的共享所有权指针

返回值

在基于所有者的顺序确定 lhs 小于 rhs 时返回 true

注解

功能特性测试 标准 功能特性
__cpp_lib_transparent_operators 201510L (C++17) 透明的 std::owner_lessstd::owner_less<void>

参阅

提供基于持有者的共享指针排序
(std::shared_ptr<T> 的公开成员函数)
提供弱指针的基于拥有者的排序
(std::weak_ptr<T> 的公开成员函数)