auto_handle::operator!

运算符用于 auto_handle 一个条件表达式。

bool operator!();

返回值

true ,如果被包装的对象无效;否则 false 。

示例

// msl_auto_handle_operator_not.cpp
// compile with: /clr
#include <msclr\auto_handle.h>

using namespace System;
using namespace msclr;

int main() {
   auto_handle<String> s1;
   auto_handle<String> s2 = "something";
   if ( s1) Console::WriteLine( "s1 is valid" );
   if ( !s1 ) Console::WriteLine( "s1 is invalid" );
   if ( s2 ) Console::WriteLine( "s2 is valid" );
   if ( !s2 ) Console::WriteLine( "s2 is invalid" );
   s2.reset();
   if ( s2 ) Console::WriteLine( "s2 is now valid" );
   if ( !s2 ) Console::WriteLine( "s2 is now invalid" );
}
  

要求

头文件 <msclr \ auto_handle.h>

命名空间 msclr

请参见

参考

auto_handle::operator bool

其他资源

auto_handle Members