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

来自cppreference.com
 
 
动态内存管理
智能指针
(C++11)
(C++11)
(C++11)
(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 前)
(C++11)(C++23 前)
杂项
(C++20)
(C++11)
(C++11)
C 库
低层内存管理
 
 
在标头 <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 前)

比较二个 polymorphic_allocator 。若二个 polymorphic_allocator 的底层 memory_resource 比较相等,则它们比较相等。

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 - 要比较的 polymorphic_allocator

返回值

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

缺陷报告

下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。

缺陷报告 应用于 出版时的行为 正确行为
LWG 3683 C++17 polymorphic_allocator 不能与能转换到它的类型比较 添加了重载