[#FOLLY_CREATE_FREE_INVOKER] = FOLLY_CREATE_FREE_INVOKER :mrdocs: * FOLLY_CREATE_FREE_INVOKER == Synopsis Declared in `<folly/functional/Invoke.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- #define FOLLY_CREATE_FREE_INVOKER(classname, funcname, ...) ---- == Description Used to create an invoker type bound to a specific free‐invocable name. Example: FOLLY_CREATE_FREE_INVOKER(foo_invoker, foo); The type `foo_invoker` is generated in the current namespace and may be used as follows: namespace Deep { struct CanFoo {}; int foo(CanFoo const&, Bar&) { return 1; } int foo(CanFoo&&, Car&&) noexcept { return 2; } } using traits = folly::invoke_traits<foo_invoker>; traits::invoke(Deep::CanFoo{}, Car{}) // 2 traits::invoke_result<Deep::CanFoo, Bar&> // has member traits::invoke_result_t<Deep::CanFoo, Bar&> // int traits::invoke_result<Deep::CanFoo, Bar&&> // empty traits::invoke_result_t<Deep::CanFoo, Bar&&> // error traits::is_invocable_v<CanFoo, Bar&> // true traits::is_invocable_v<CanFoo, Bar&&> // false traits::is_invocable_r_v<int, CanFoo, Bar&> // true traits::is_invocable_r_v<char*, CanFoo, Bar&> // false traits::is_nothrow_invocable_v<CanFoo, Bar&> // false traits::is_nothrow_invocable_v<CanFoo, Car&&> // true traits::is_nothrow_invocable_v<int, CanFoo, Bar&> // false traits::is_nothrow_invocable_v<char*, CanFoo, Bar&> // false traits::is_nothrow_invocable_v<int, CanFoo, Car&&> // true traits::is_nothrow_invocable_v<char*, CanFoo, Car&&> // false When a name has one or more primary definition in a fixed set of namespaces and alternate definitions in the namespaces of its arguments, the primary definitions may automatically be found as follows: FOLLY_CREATE_FREE_INVOKER(swap_invoker, swap, std); In this case, `swap_invoke_traits::invoke(int&, int&)` will use the primary definition found in `namespace std` relative to the current namespace, which may be equivalent to `namespace ::std`. In contrast: namespace Deep { struct HasData {}; void swap(HasData&, HasData&) { throw 7; } } using traits = invoke_traits<swap_invoker>; HasData a, b; traits::invoke(a, b); // throw 7 == Parameters [cols="1,4"] |=== | Name| Description | *classname* | the name of the generated invoker type | *funcname* | the free‐invocable name to bind |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#