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

来自cppreference.com


 
 
内存管理库
分配器
内存资源
未初始化存储 (C++20 前*)
垃圾收集器支持 (C++23 前)
 
 
template< class T1, class T2 >
bool operator==( const allocator<T1>& lhs, const allocator<T2>& rhs ) throw();
(1) (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 起)
template< class T1, class T2 >
bool operator!=( const allocator<T1>& lhs, const allocator<T2>& rhs ) throw();
(2) (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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.