FOLLY_CREATE_STATIC_MEMBER_INVOKER

* FOLLY_CREATE_STATIC_MEMBER_INVOKER

Synopsis

Declared in <folly/functional/Invoke.h>

#define FOLLY_CREATE_STATIC_MEMBER_INVOKER(classname, membername)

Description

Used to create an invoker type template bound to a specific static-member- invocable name.

Example:

FOLLY_CREATE_STATIC_MEMBER_INVOKER(foo_invoker, foo);

The type template foo_invoker is generated in the current namespace and may be used as follows:

struct CanFoo { static int foo(Bar&) { return 1; } static int foo(Car&&) noexcept { return 2; } };

using traits = folly::invoke_traits<foo_invoker<CanFoo>>;

traits::invoke(Car{}) // 2

traits::invoke_result<Bar&> // has member traits::invoke_result_t<Bar&> // int traits::invoke_result<Bar&&> // empty traits::invoke_result_t<Bar&&> // error

traits::is_invocable_v<Bar&> // true traits::is_invocable_v<Bar&&> // false

traits::is_invocable_r_v<int, Bar&> // true traits::is_invocable_r_v<char*, Bar&> // false

traits::is_nothrow_invocable_v<Bar&> // false traits::is_nothrow_invocable_v<Car&&> // true

traits::is_nothrow_invocable_v<int, Bar&> // false traits::is_nothrow_invocable_v<char*, Bar&> // false traits::is_nothrow_invocable_v<int, Car&&> // true traits::is_nothrow_invocable_v<char*, Car&&> // false

Parameters

NameDescription
classnamethe name of the generated invoker type template
membernamethe static-member-invocable name to bind