命名空间
变体
操作

std::pmr::operator==, std::pmr::operator!=

来自 cppreference.cn
 
 
内存管理库
(仅供演示*)
未初始化内存算法
(C++17)
(C++17)
(C++17)
受约束的未初始化
内存算法
C 库

分配器
内存资源
垃圾回收支持
(C++11)(直到 C++23)
(C++11)(直到 C++23)
(C++11)(直到 C++23)
(C++11)(直到 C++23)
(C++11)(直到 C++23)
(C++11)(直到 C++23)
未初始化存储
(直到 C++20*)
(直到 C++20*)
显式生命周期管理
 
 
定义于头文件 <memory_resource>
template< class T1, class T2 >

bool operator==( const std::pmr::polymorphic_allocator<T1>& lhs,

                 const std::pmr::polymorphic_allocator<T2>& rhs ) noexcept;
(1) (自 C++17 起)
friend bool operator==( const polymorphic_allocator& lhs,
                        const polymorphic_allocator& rhs ) noexcept;
(2) (自 C++17 起)
template< class T1, class T2 >

bool operator!=( const std::pmr::polymorphic_allocator<T1>& lhs,

                 const std::pmr::polymorphic_allocator<T2>& rhs ) noexcept;
(3) (自 C++17 起)
(直到 C++20)
friend bool operator!=( const polymorphic_allocator& lhs,
                        const polymorphic_allocator& rhs ) noexcept;
(4) (自 C++17 起)
(直到 C++20)

比较两个多态分配器。如果它们的基础内存资源比较相等,则两个多态分配器比较相等。

1) 返回 *lhs.resource() == *rhs.resource()
2)(1) 相同,允许转换为 polymorphic_allocator
此函数对于普通的非限定查找限定查找不可见,并且只能通过实参依赖查找在 std::pmr::polymorphic_allocator 是参数的关联类时找到。
3) 返回 !(lhs == rhs)
4)(3) 相同,允许转换为 polymorphic_allocator
此函数对于普通的非限定查找限定查找不可见,并且只能通过实参依赖查找在 std::pmr::polymorphic_allocator 是参数的关联类时找到。

!= 运算符是从 operator== 合成 的。

(自 C++20 起)

[编辑] 参数

lhs, rhs - 要比较的多态分配器

[编辑] 返回值

1,2) *lhs.resource() == *rhs.resource()
3,4) !(lhs == rhs)

[编辑] 缺陷报告

以下行为变更缺陷报告已追溯应用于先前发布的 C++ 标准。

DR 应用于 已发布行为 正确行为
LWG 3683 C++17 polymorphic_allocator 无法与可转换为它的类型进行比较 添加了重载