operator== (<memory>)
相等的測試在物件之間。
template<class Type, class Other>
bool operator==(
const allocator<Type>& _Left,
const allocator<Other>& _Right
) throw();
template<class Ty1, class Del1, class Ty2, class Del2>
bool operator==(
const unique_ptr<Ty1, Del1>& _Left,
const unique_ptr<Ty2, Del2>& _Right
);
template<class Ty1, class Ty2>
bool operator==(
const shared_ptr<Ty1>& _Left;,
const shared_ptr<Ty2>& _Right
);
參數
_Left
為要測試是否相等的其中一個物件。_Right
為要測試是否相等的其中一個物件。Ty1
左共用指標控制項型別。Ty2
正確的共用指標控制項型別。
傳回值
true ,如果物件相等,則為 false ,如果物件不相等。
備註
第一個範本運算子會傳回 true。(所有預設配置器相等)。
第二和第三個樣板運算子會傳回 _Left.get() == _Right.get()。
範例
// memory_op_eq.cpp
// compile with: /EHsc
#include <memory>
#include <iostream>
#include <vector>
using namespace std;
int main( )
{
allocator<char> Alloc;
vector <int>:: allocator_type v1Alloc;
allocator<char> cAlloc(Alloc);
allocator<int> cv1Alloc(v1Alloc);
if ( cv1Alloc == v1Alloc )
cout << "The allocator objects cv1Alloc & v1Alloc are equal."
<< endl;
else
cout << "The allocator objects cv1Alloc & v1Alloc are not equal."
<< endl;
if ( cAlloc == Alloc )
cout << "The allocator objects cAlloc & Alloc are equal."
<< endl;
else
cout << "The allocator objects cAlloc & Alloc are not equal."
<< endl;
}
// std_tr1__memory__operator_eq.cpp
// compile with: /EHsc
#include <memory>
#include <iostream>
int main()
{
std::shared_ptr<int> sp0(new int(0));
std::shared_ptr<int> sp1(new int(0));
std::cout << "sp0 == sp0 == " << std::boolalpha
<< (sp0 == sp0) << std::endl;
std::cout << "sp0 == sp1 == " << std::boolalpha
<< (sp0 == sp1) << std::endl;
return (0);
}
需求
標頭: <memory>
命名空間: std