命名空间
变体
操作

operator==,!=(std::allocator)

来自 cppreference.cn
< cpp‎ | 内存‎ | allocator
 
 
内存管理库
(仅作说明*)
未初始化内存算法
(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*)
显式生命周期管理
 
std::allocator
成员函数
(C++20 前)
(C++20 前)
(C++20 前)
(C++20 前)
非成员函数
operator==operator!=
(C++20 前)
 
(1)
template< class T1, class T2 >
bool operator==( const allocator<T1>& lhs, const allocator<T2>& rhs ) throw();
(C++11 前)
template< class T1, class T2 >
bool operator==( const allocator<T1>& lhs, const allocator<T2>& rhs ) noexcept;
(C++11 起)
(C++20 前)
template< class T1, class T2 >

constexpr bool

    operator==( const allocator<T1>& lhs, const allocator<T2>& rhs ) noexcept;
(C++20 起)
(2)
template< class T1, class T2 >
bool operator!=( const allocator<T1>& lhs, const allocator<T2>& rhs ) throw();
(C++11 前)
template< class T1, class T2 >
bool operator!=( const allocator<T1>& lhs, const allocator<T2>& rhs ) noexcept;
(C++11 起)
(C++20 前)

比较两个默认分配器。因为默认分配器是无状态的,所以两个默认分配器始终相等。

1) 返回 true
2) 返回 false

!= 运算符由 operator== 合成

(C++20 起)

[编辑] 参数

lhs, rhs - 要比较的默认分配器

[编辑] 返回值

1) true
2) false