is_function Class

 

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

Tests if type is a function type.

template <class Ty>  
struct is_function;  

Parameters

Ty
The type to query.

An instance of the type predicate holds true if the type Ty is a function type, otherwise it holds false.

// std_tr1__type_traits__is_function.cpp   
// compile with: /EHsc   
#include <type_traits>   
#include <iostream>   
  
struct trivial   
    {   
    int val;   
    };   
  
struct functional   
    {   
    int f();   
    };   
  
int main()   
    {   
    std::cout << "is_function<trivial> == " << std::boolalpha   
        << std::is_function<trivial>::value << std::endl;   
    std::cout << "is_function<functional> == " << std::boolalpha   
        << std::is_function<functional>::value << std::endl;   
    std::cout << "is_function<float()> == " << std::boolalpha   
        << std::is_function<float()>::value << std::endl;   
  
    return (0);   
    }  
  

is_function<trivial> == false  
is_function<functional> == false  
is_function<float()> == true  

Header: <type_traits>

Namespace: std

<type_traits>
is_object Class

Show: