__if_not_exists Statement


For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.

For the latest documentation on Visual Studio 2017, see __if_not_exists Statement on docs.microsoft.com. The __if_not_exists statement tests whether the specified identifier exists. If the identifier does not exist, the specified statement block is executed.

__if_not_exists ( identifier ) {   


identifierThe identifier whose existence you want to test.
statementsOne or more statements to execute if identifier does not exist.
System_CAPS_ICON_caution.jpg Caution

To achieve the most reliable results, use the __if_not_exists statement under the following constraints.

  • Apply the __if_not_exists statement to only simple types, not templates.

  • Apply the __if_not_exists statement to identifiers both inside or outside a class. Do not apply the __if_not_exists statement to local variables.

  • Use the __if_not_exists statement only in the body of a function. Outside of the body of a function, the __if_not_exists statement can test only fully defined types.

  • When you test for overloaded functions, you cannot test for a specific form of the overload.

The complement to the __if_not_exists statement is the __if_exists statement.

For an example about how to use __if_not_exists, see __if_exists Statement.

Selection Statements
__if_exists Statement