Partager via


auto_handle::operator!

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at auto_handle::operator!.

Operator for using auto_handle in a conditional expression.

Syntax

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

auto_handle Members
auto_handle::operator bool