다음을 통해 공유


auto_handle::operator!

Operator for using auto_handle in a conditional expression.

bool operator!();

Return Value

true if the wrapped object is invalid; false otherwise.

Example

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

s1 is invalid
s2 is valid
s2 is now invalid

Requirements

Header file <msclr\auto_handle.h>

Namespace msclr

See Also

Concepts

auto_handle Members

auto_handle::operator bool