std::pmr::operator==, std::pmr::operator!=
// 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
比较两个多态分配器。如果它们的底层内存资源比较相等,则两个多态分配器比较相等。
-
返回 `*lhs.resource() == *rhs.resource()`
-
与 (1) 相同,允许转换为 polymorphic_allocator。
此函数对普通的非限定或限定查找不可见,只能通过参数相关的查找找到,当 std::pmr::polymorphic_allocator 是参数的关联类时。
-
返回 `!(lhs == rhs)`
-
与 (3) 相同,允许转换为 polymorphic_allocator。
此函数对普通的非限定或限定查找不可见,只能通过参数相关的查找找到,当 std::pmr::polymorphic_allocator 是参数的关联类时。
参数
lhs
, rhs
- 要比较的多态分配器
返回值
1-2) *lhs.resource() == *rhs.resource()
3-4) !(lhs == rhs)
缺陷报告
以下改变行为的缺陷报告已追溯应用于先前发布的 C++ 标准。
DR | 应用于 | 发布时的行为 | 正确行为 |
---|---|---|---|
LWG 3683 | C++17 | polymorphic_allocator 无法与可转换为它的类型进行比较 | 已添加重载 |