[#FOLLY_FOR_EACH_THIS_OVERLOAD_IN_CLASS_BODY_DELEGATE]
= FOLLY&lowbar;FOR&lowbar;EACH&lowbar;THIS&lowbar;OVERLOAD&lowbar;IN&lowbar;CLASS&lowbar;BODY&lowbar;DELEGATE
:mrdocs:

FOLLY&lowbar;FOR&lowbar;EACH&lowbar;THIS&lowbar;OVERLOAD&lowbar;IN&lowbar;CLASS&lowbar;BODY&lowbar;DELEGATE

== Synopsis

Declared in `&lt;folly&sol;Utility&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
#define FOLLY&lowbar;FOR&lowbar;EACH&lowbar;THIS&lowbar;OVERLOAD&lowbar;IN&lowbar;CLASS&lowbar;BODY&lowbar;DELEGATE(MEMBER, DELEGATE)

----

== Description

Helper macro to add 4 delegated, qualifier&hyphen;overloaded methods to a class

Example&colon;

template &lt;typename T&gt; class optional &lcub; public&colon; bool has&lowbar;value() const&semi;

T&amp; value() &amp; &lcub; if (!has&lowbar;value()) &lcub; throw std&colon;&colon;bad&lowbar;optional&lowbar;access()&semi; &rcub; return m&lowbar;value&semi; &rcub;

const T&amp; value() const&amp; &lcub; if (!has&lowbar;value()) &lcub; throw std&colon;&colon;bad&lowbar;optional&lowbar;access()&semi; &rcub; return m&lowbar;value&semi; &rcub;

T&amp;&amp; value() &amp;&amp; &lcub; if (!has&lowbar;value()) &lcub; throw std&colon;&colon;bad&lowbar;optional&lowbar;access()&semi; &rcub; return std&colon;&colon;move(m&lowbar;value)&semi; &rcub;

const T&amp;&amp; value() const&amp;&amp; &lcub; if (!has&lowbar;value()) &lcub; throw std&colon;&colon;bad&lowbar;optional&lowbar;access()&semi; &rcub; return std&colon;&colon;move(m&lowbar;value)&semi; &rcub; &rcub;&semi;

This is equivalent to

template &lt;typename T&gt; class optional &lcub; template &lt;typename Self&gt; decltype(auto) value&lowbar;impl(Self&amp;&amp; self) &lcub; if (!self&period;has&lowbar;value()) &lcub; throw std&colon;&colon;bad&lowbar;optional&lowbar;access()&semi; &rcub; return std&colon;&colon;forward&lt;Self&gt;(self)&period;m&lowbar;value&semi; &rcub; &sol;&sol; &period;&period;&period;

public&colon; bool has&lowbar;value() const&semi;

FOLLY&lowbar;FOR&lowbar;EACH&lowbar;THIS&lowbar;OVERLOAD&lowbar;IN&lowbar;CLASS&lowbar;BODY&lowbar;DELEGATE(value, value&lowbar;impl)&semi; &rcub;&semi;

Note&colon; This can be migrated to C&plus;&plus;23&apos;s deducing this&colon; https&colon;&sol;&sol;www&period;open&hyphen;std&period;org&sol;jtc1&sol;sc22&sol;wg21&sol;docs&sol;papers&sol;2021&sol;p0847r7&period;html

== Parameters

[cols="1,4"]
|===
| Name| Description
| *MEMBER*
| Name of the member function to generate&period;
| *DELEGATE*
| Name of the static implementation to delegate to&period;
|===


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