跳到主要内容

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

自 C++17 起
// 1)
template< class T1, class T2 >
bool operator==( const std::pmr::polymorphic_allocator<T1>& lhs,
const std::pmr::polymorphic_allocator<T2>& rhs ) noexcept;
// 2)
friend bool operator==( const polymorphic_allocator& lhs,
const polymorphic_allocator& rhs ) noexcept;
// 3)
template< class T1, class T2 >
bool operator!=( const std::pmr::polymorphic_allocator<T1>& lhs,
const std::pmr::polymorphic_allocator<T2>& rhs ) noexcept; // until C++20
// 4)
friend bool operator!=( const polymorphic_allocator& lhs,
const polymorphic_allocator& rhs ) noexcept; // until 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 3683C++17polymorphic_allocator 无法与可转换为它的类型进行比较已添加重载

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

自 C++17 起
// 1)
template< class T1, class T2 >
bool operator==( const std::pmr::polymorphic_allocator<T1>& lhs,
const std::pmr::polymorphic_allocator<T2>& rhs ) noexcept;
// 2)
friend bool operator==( const polymorphic_allocator& lhs,
const polymorphic_allocator& rhs ) noexcept;
// 3)
template< class T1, class T2 >
bool operator!=( const std::pmr::polymorphic_allocator<T1>& lhs,
const std::pmr::polymorphic_allocator<T2>& rhs ) noexcept; // until C++20
// 4)
friend bool operator!=( const polymorphic_allocator& lhs,
const polymorphic_allocator& rhs ) noexcept; // until 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 3683C++17polymorphic_allocator 无法与可转换为它的类型进行比较已添加重载