次の方法で共有


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
    等価をテストするオブジェクトの 1 つが。

  • _Right
    等価をテストするオブジェクトの 1 つが。

  • Ty1
    左辺の共有ポインターによって制御される型。

  • Ty2
    右辺の共有ポインターによって制御される型。

戻り値

オブジェクトがではないオブジェクトが等しい truefalse。

解説

最初のテンプレート演算子はを返します。(すべての既定のアロケーターは同等です)。

2 番目と 3 _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

参照

関連項目

auto_ptr Class

shared_ptr クラス

unique_ptr Class

その他の技術情報

auto_ptr のメンバー

shared_ptr:: operator==

unique_ptr のメンバー