is_union Class
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

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::tr1::is_union<trivial>::value << std::endl; 
    std::cout << "is_union<int> == " << std::boolalpha 
        << std::tr1::is_union<int>::value << std::endl; 
    std::cout << "is_union<ints> == " << std::boolalpha 
        << std::tr1::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::tr1

Show:
© 2016 Microsoft