[#RPCMethod-MaybeArg]
= xref:RPCMethod.adoc[RPCMethod]::MaybeArg
:relfileprefix: ../
:mrdocs:

Helper to get an optional request argument&period;

== Synopsis

Declared in `&lt;rpc&sol;util&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;typename R&gt;
auto
MaybeArg(std::string&lowbar;view key) const;
----

== Description

Use this function when the argument is optional and does not have a default value&period; If the argument is required or has a default value, use Arg instead&period;

This function only works during m&lowbar;fun(), i&period;e&period;, it should only be used in RPC method implementations&period; It internally checks whether the user&hyphen;passed argument isNull() and parses (from JSON) and returns the user&hyphen;passed argument, or a falsy value if no argument was passed&period;

The instantiation of this helper for type R must match the corresponding RPCArg&colon;&colon;Type&period;

== Return Value

For trivially copyable types, a std&colon;&colon;optional&lt;R&gt; is returned&period; For other types, a R&ast; pointer to the argument is returned&period; If the argument is not provided, std&colon;&colon;nullopt or a null pointer is returned&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *key*
| The name of the argument to fetch&period;
|===

== See Also

Arg for handling arguments that are required or have a default value&period;


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