跳到主要内容

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

自 C++20 起
// 1)
template< class T1, class T2 >
constexpr bool operator==( const allocator<T1>& lhs, const allocator<T2>& rhs ) noexcept;
从 C++11 起,直到 C++20
// 1)
template< class T1, class T2 >
bool operator==( const allocator<T1>& lhs, const allocator<T2>& rhs ) noexcept;
// 2)
template< class T1, class T2 >
bool operator!=( const allocator<T1>& lhs, const allocator<T2>& rhs ) noexcept;
直到 C++11
// 1)
template< class T1, class T2 >
bool operator==( const allocator<T1>& lhs, const allocator<T2>& rhs ) throw();
// 2)
template< class T1, class T2 >
bool operator!=( const allocator<T1>& lhs, const allocator<T2>& rhs ) throw();

比较两个默认分配器。由于默认分配器是无状态的,因此两个默认分配器始终相等。

  1. 返回 true
  2. 返回 false
!= 运算符是从 == 运算符合成的。 (自 C++20 起)

参数

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

返回值

  1. true
  2. false

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

自 C++20 起
// 1)
template< class T1, class T2 >
constexpr bool operator==( const allocator<T1>& lhs, const allocator<T2>& rhs ) noexcept;
从 C++11 起,直到 C++20
// 1)
template< class T1, class T2 >
bool operator==( const allocator<T1>& lhs, const allocator<T2>& rhs ) noexcept;
// 2)
template< class T1, class T2 >
bool operator!=( const allocator<T1>& lhs, const allocator<T2>& rhs ) noexcept;
直到 C++11
// 1)
template< class T1, class T2 >
bool operator==( const allocator<T1>& lhs, const allocator<T2>& rhs ) throw();
// 2)
template< class T1, class T2 >
bool operator!=( const allocator<T1>& lhs, const allocator<T2>& rhs ) throw();

比较两个默认分配器。由于默认分配器是无状态的,因此两个默认分配器始终相等。

  1. 返回 true
  2. 返回 false
!= 运算符是从 == 运算符合成的。 (自 C++20 起)

参数

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

返回值

  1. true
  2. false