次の方法で共有


is_function クラス

型が関数型であるかどうかをテストします。

構文

template <class Ty>
struct is_function;

パラメーター

Ty
照会する型。

解説

Ty が関数型である場合、型の述語のインスタンスは true を保持します。それ以外の場合は、false を保持します。

// std__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

必要条件

ヘッダー: <type_traits>

名前空間: std

関連項目

<type_traits>
is_object クラス