operator!= (<memory>)

不相等测试的对象之间。

template<class Type, class Other>
   bool operator!=(
      const allocator<Type>& _Left,
      const allocator<Other>& _Right
   ) throw();
template<class Type1, class Del1, class Type2, class Del2>
    bool operator!=(
        const unique_ptr<Type1, Del1>& _Left,
        const unique_ptr<Type2&, 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 对象是相同的。

备注

第一个模板运算符返回错误。(所有默认分配程序相同。)

第二个和第三模板运算符返回 !(_Left == _Right)。

示例

// memory_op_me.cpp
// compile with: /EHsc
#include <memory>
#include <iostream>
#include <vector>

using namespace std;

int main( ) 
{
   allocator<double> Alloc;
   vector <char>:: allocator_type v1Alloc;

   if ( Alloc != v1Alloc )
      cout << "The allocator objects Alloc & v1Alloc not are equal."
           << endl;
   else
      cout << "The allocator objects Alloc & v1Alloc are equal."
           << endl;
}
  

 

// std_tr1__memory__operator_ne.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); 
    } 
 
  

要求

页眉: <内存>

命名空间: std

请参见

参考

auto_ptr 类

shared_ptr 类

unique_ptr 类

其他资源

auto_ptr 成员

shared_ptr::operator! =

unique_ptr 成员