Namespaces
Variants

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

From cppreference.net
Memory management library
( exposition only* )
Allocators
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Memory resources
Uninitialized storage (until C++20)
( until C++20* )
( until C++20* )
( until C++20* )

Garbage collector support (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
(C++11) (until C++23)
定义于头文件 <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== 合成生成

(since C++20)

参数

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

返回值

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

缺陷报告

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

DR 适用范围 发布时的行为 正确行为
LWG 3683 C++17 polymorphic_allocator 无法与可转换至该类型的其他类型进行比较 已添加重载