[#bsl-stop_callback-06-2constructor-04]
= xref:bsl.adoc[bsl]::xref:bsl/stop_callback-06.adoc[stop&lowbar;callback]::stop&lowbar;callback
:relfileprefix: ../../
:mrdocs:

Create a `stop&lowbar;callback` that stores a callable constructed from `arg` and registers it with the stop state of `token`, if any&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;stoptoken&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class t&lowbar;ARG&gt;
explicit
stop&lowbar;callback(
    xref:bsl/stop_token.adoc[stop&lowbar;token] const& token,
    t&lowbar;ARG&& arg,
    xref:bsl/stop_callback-06/allocator_type.adoc[allocator&lowbar;type] const& alloc = allocator&lowbar;type());
----

== Description

If `t&lowbar;CALLBACK` is allocator&hyphen;aware, the optionally specified `alloc` supplies memory&semi; otherwise `alloc` is ignored&period; If `token` already refers to a stop&hyphen;requested state, invoke the callback before returning&semi; otherwise register it with that stop state&period; Unlike `std&colon;&colon;stop&lowbar;callback`, these constructors are not currently `noexcept`&period; If `token` is an rvalue reference, it is unspecified whether this function moves from `token`&period;


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