auto_gcroot::operator!

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

bool operator!() const;

返回值

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

示例

// msl_auto_gcroot_operator_not.cpp
// compile with: /clr
#include <msclr\auto_gcroot.h>

using namespace System;
using namespace msclr;

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

要求

头文件 <msclr \ auto_gcroot.h>

命名空间 msclr

请参见

参考

auto_gcroot::operator bool

其他资源

auto_gcroot Members