is_compound Class

 

Visual C++ in Visual Studio 2015

The latest version of this topic can be found at is_compound Class.

Tests if the specified type is not fundamental.

template <class Ty>  
struct is_compound;  

Parameters

Ty
The type to query.

An instance of the type predicate holds false if the type of Ty is a fundamental type (that is, if is_fundamental<``Ty``> holds true); otherwise, it holds true. Thus, the predicate holds true if Ty is an array type, a function type, a pointer to void or an object or a function, a reference, a class, a union, an enumeration, or a pointer to non-static class member, or a cv-qualified form of one of them.

// std_tr1__type_traits__is_compound.cpp   
// compile with: /EHsc   
#include <type_traits>   
#include <iostream>   
  
struct trivial   
    {   
    int val;   
    };   
  
int main()   
    {   
    std::cout << "is_compound<trivial> == " << std::boolalpha   
        << std::is_compound<trivial>::value << std::endl;   
    std::cout << "is_compound<int[]> == " << std::boolalpha   
        << std::is_compound<int[]>::value << std::endl;   
    std::cout << "is_compound<int()> == " << std::boolalpha   
        << std::is_compound<int()>::value << std::endl;   
    std::cout << "is_compound<int&> == " << std::boolalpha   
        << std::is_compound<int&>::value << std::endl;   
    std::cout << "is_compound<void *> == " << std::boolalpha   
        << std::is_compound<void *>::value << std::endl;   
    std::cout << "is_compound<int> == " << std::boolalpha   
        << std::is_compound<int>::value << std::endl;   
  
    return (0);   
    }  
  

is_compound<trivial> == true  
is_compound<int[]> == true  
is_compound<int()> == true  
is_compound<int&> == true  
is_compound<void *> == true  
is_compound<int> == false  

Header: <type_traits>

Namespace: std

<type_traits>
is_class Class

Show: