Namespaces
Variants

std::meta::is_function_type

From cppreference.com
< cpp | meta
 
 
 
Reflection library
 
Reflection types and queries
Type properties
Type property queries
 
Defined in header <meta>
consteval bool is_function_type( std::meta::info r );
(since C++26)

Returns true if r represents a function type. Otherwise returns false.

Types like std::function, lambdas, classes with overloaded operator() and pointers to functions are not function types.

Parameters

r - a reflection value

Return value

true if r represents a function type; otherwise false.

Exceptions

Throws std::meta::exception if r does not represent a type or type alias.

Example

#include <functional>
#include <meta>

int f();

struct O
{
    void operator()() {}
};

static_assert
(""
    &&   is_function_type(^^decltype(f))
    && ! is_function_type(^^int)
    &&   is_function_type(^^int(int))
    && ! is_function_type(^^decltype([]{}))
    &&   is_function_type(^^O())
    && ! is_function_type(^^std::function<void()>)
);

struct A
{
    static int foo();
    int fun() const&;
    int operator()();
};

static_assert
(""
    && ! is_function_type(^^A)
    &&   is_function_type(^^decltype(A::foo))
    && ! is_function_type(^^decltype(&A::fun))
    && ! is_function_type(^^decltype(&A::operator()))
);

template<typename>
struct is_member_pointer {};

template<class T, class U>
struct is_member_pointer<U T::*> { using type = U; };

using T = is_member_pointer<decltype(&A::fun)>::type; // T is int() const&
static_assert(is_function_type(^^T));

int main() {}

See also

checks if the reflected type can be invoked (as if by std::invoke) with the given argument types
(function template) [edit]
checks if reflected type is an object type
(function) [edit]
checks if reflected type is a non-union class type
(function) [edit]
checks if a type is a function type
(class template) [edit]
Morty Proxy This is a proxified and sanitized view of the page, visit original site.