Export (0) Print
Expand All
Expand Minimize

is_union Class

Tests if type is a union.

template<class Ty>
    struct is_union;

Ty

The type to query.

An instance of the type predicate holds true if the type Ty is a union type or a cv-qualified form of a union type, otherwise it holds false.

 

// std_tr1__type_traits__is_union.cpp 
// compile with: /EHsc 
#include <type_traits> 
#include <iostream> 
 
struct trivial 
    { 
    int val; 
    }; 
 
union ints 
    { 
    int in; 
    long lo; 
    }; 
 
int main() 
    { 
    std::cout << "is_union<trivial> == " << std::boolalpha 
        << std::is_union<trivial>::value << std::endl; 
    std::cout << "is_union<int> == " << std::boolalpha 
        << std::is_union<int>::value << std::endl; 
    std::cout << "is_union<ints> == " << std::boolalpha 
        << std::is_union<ints>::value << std::endl; 
 
    return (0); 
    } 
 
is_union<trivial> == false
is_union<int> == false
is_union<ints> == true

Header: <type_traits>

Namespace: std

Community Additions

ADD
Show:
© 2014 Microsoft