名稱空間
變體
操作

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

來自 cppreference.com
 
 
記憶體管理庫
(僅作說明*)
未初始化記憶體演算法
(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++ 標準。

缺陷報告 應用於 釋出時的行為 正確的行為
LWG 3683 C++17 polymorphic_allocator 無法與可轉換為它的型別進行比較 添加了過載