[#FOLLY_CREATE_FREE_INVOKER]
= FOLLY&lowbar;CREATE&lowbar;FREE&lowbar;INVOKER
:mrdocs:

&ast; FOLLY&lowbar;CREATE&lowbar;FREE&lowbar;INVOKER

== Synopsis

Declared in `&lt;folly&sol;functional&sol;Invoke&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
#define FOLLY&lowbar;CREATE&lowbar;FREE&lowbar;INVOKER(classname, funcname, ...)

----

== Description

Used to create an invoker type bound to a specific free&hyphen;invocable name&period;

Example&colon;

FOLLY&lowbar;CREATE&lowbar;FREE&lowbar;INVOKER(foo&lowbar;invoker, foo)&semi;

The type `foo&lowbar;invoker` is generated in the current namespace and may be used as follows&colon;

namespace Deep &lcub; struct CanFoo &lcub;&rcub;&semi; int foo(CanFoo const&amp;, Bar&amp;) &lcub; return 1&semi; &rcub; int foo(CanFoo&amp;&amp;, Car&amp;&amp;) noexcept &lcub; return 2&semi; &rcub; &rcub;

using traits &equals; folly&colon;&colon;invoke&lowbar;traits&lt;foo&lowbar;invoker&gt;&semi;

traits&colon;&colon;invoke(Deep&colon;&colon;CanFoo&lcub;&rcub;, Car&lcub;&rcub;) &sol;&sol; 2

traits&colon;&colon;invoke&lowbar;result&lt;Deep&colon;&colon;CanFoo, Bar&amp;&gt; &sol;&sol; has member traits&colon;&colon;invoke&lowbar;result&lowbar;t&lt;Deep&colon;&colon;CanFoo, Bar&amp;&gt; &sol;&sol; int traits&colon;&colon;invoke&lowbar;result&lt;Deep&colon;&colon;CanFoo, Bar&amp;&amp;&gt; &sol;&sol; empty traits&colon;&colon;invoke&lowbar;result&lowbar;t&lt;Deep&colon;&colon;CanFoo, Bar&amp;&amp;&gt; &sol;&sol; error

traits&colon;&colon;is&lowbar;invocable&lowbar;v&lt;CanFoo, Bar&amp;&gt; &sol;&sol; true traits&colon;&colon;is&lowbar;invocable&lowbar;v&lt;CanFoo, Bar&amp;&amp;&gt; &sol;&sol; false

traits&colon;&colon;is&lowbar;invocable&lowbar;r&lowbar;v&lt;int, CanFoo, Bar&amp;&gt; &sol;&sol; true traits&colon;&colon;is&lowbar;invocable&lowbar;r&lowbar;v&lt;char&ast;, CanFoo, Bar&amp;&gt; &sol;&sol; false

traits&colon;&colon;is&lowbar;nothrow&lowbar;invocable&lowbar;v&lt;CanFoo, Bar&amp;&gt; &sol;&sol; false traits&colon;&colon;is&lowbar;nothrow&lowbar;invocable&lowbar;v&lt;CanFoo, Car&amp;&amp;&gt; &sol;&sol; true

traits&colon;&colon;is&lowbar;nothrow&lowbar;invocable&lowbar;v&lt;int, CanFoo, Bar&amp;&gt; &sol;&sol; false traits&colon;&colon;is&lowbar;nothrow&lowbar;invocable&lowbar;v&lt;char&ast;, CanFoo, Bar&amp;&gt; &sol;&sol; false traits&colon;&colon;is&lowbar;nothrow&lowbar;invocable&lowbar;v&lt;int, CanFoo, Car&amp;&amp;&gt; &sol;&sol; true traits&colon;&colon;is&lowbar;nothrow&lowbar;invocable&lowbar;v&lt;char&ast;, CanFoo, Car&amp;&amp;&gt; &sol;&sol; 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&colon;

FOLLY&lowbar;CREATE&lowbar;FREE&lowbar;INVOKER(swap&lowbar;invoker, swap, std)&semi;

In this case, `swap&lowbar;invoke&lowbar;traits&colon;&colon;invoke(int&amp;, int&amp;)` will use the primary definition found in `namespace std` relative to the current namespace, which may be equivalent to `namespace &colon;&colon;std`&period; In contrast&colon;

namespace Deep &lcub; struct HasData &lcub;&rcub;&semi; void swap(HasData&amp;, HasData&amp;) &lcub; throw 7&semi; &rcub; &rcub;

using traits &equals; invoke&lowbar;traits&lt;swap&lowbar;invoker&gt;&semi;

HasData a, b&semi; traits&colon;&colon;invoke(a, b)&semi; &sol;&sol; throw 7

== Parameters

[cols="1,4"]
|===
| Name| Description
| *classname*
| the name of the generated invoker type
| *funcname*
| the free&hyphen;invocable name to bind
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
