case (C++)

 

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

Used with the switch_type attribute in a union.

  
      [ case(  
   value  
) ]  

Parameters

value
A possible input value for which you want to provide processing. The type of value can be one of the following types:

  • int

  • char

  • boolean

  • enum

or an identifier of such a type.

The case C++ attribute has the same functionality as the case MIDL attribute. This attribute is only used with the switch_type attribute.

The following code shows a use of the case attribute:

// cpp_attr_ref_case.cpp  
// compile with: /LD  
#include <unknwn.h>  
[export]  
struct SizedValue2 {  
   [switch_type(char), switch_is(kind)] union {  
      [case(1), string]  
          wchar_t* wval;  
      [default, string]  
          char* val;  
   };  
    char kind;  
};  
[module(name="ATLFIRELib")];  

Attribute Context

Applies toMember of a class or struct
RepeatableNo
Required attributesNone
Invalid attributesNone

For more information about the attribute contexts, see Attribute Contexts.

IDL Attributes
Typedef, Enum, Union, and Struct Attributes
Class Attributes
Attributes Samples

Show: