Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add an exposition-only utility for emplacing immovable types in containers #178

Merged
merged 4 commits into from
Feb 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 22 additions & 15 deletions execution.bs
Original file line number Diff line number Diff line change
Expand Up @@ -5020,13 +5020,33 @@ enum class forward_progress_guarantee {
destination scheduler to select a customization.</span>

11. <pre highlight="c++">
template&lt;<i>callable</i> Fun>
requires is_nothrow_move_constructible_v&lt;Fun>
struct <i>emplace-from</i> { // exposition only
Fun <i>fun</i>; // exposition only
using type = <i>call-result-t</i>&lt;Fun>;

constexpr operator type() && noexcept(<i>nothrow-callable</i>&lt;Fun>) {
return std::move(<i>fun</i>)();
}

constexpr type operator()() && noexcept(<i>nothrow-callable</i>&lt;Fun>) {
return std::move(<i>fun</i>)();
}
};
</pre>

1. <span class="wg21note"><i>`emplace-from`</i> is used to emplace
non-movable types into containers like `tuple`, `optional`, and `variant`.</span>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unclear to me why tuple, optional, and variant are considered as containers here.


12. <pre highlight="c++">
struct <i>on-stop-request</i> {
in_place_stop_source& stop_src;
void operator()() noexcept { stop_src.request_stop(); }
};
</pre>

12. <pre highlight="c++">
13. <pre highlight="c++">
template&lt;class... T>
struct <i>product-type</i> {
using type<sub><i>0</i></sub> = T<sub><i>0</i></sub>; // exposition only
Expand All @@ -5045,19 +5065,6 @@ enum class forward_progress_guarantee {
<code><i>product-type</i></code> is usable as the initializer of a
structured binding declaration [dcl.struct.bind].</span>

13. <pre highlight="c++">
template&lt;<i>callable</i> Fn>
struct <i>emplacer</i> { // exposition only
Fn fn; // exposition only
operator <i>call-result-t</i>&lt;Fn> () && noexcept(<i>nothrow-callable</i>&lt;Fn>) {
return std::move(fn)();
}
};
</pre>

1. <span class="wg21note">The type `emplacer<Fn>` is used to emplace non-movable
types into containers like `tuple`, `optional`, and `variant`.</span>

14. <pre highlight="c++">
template &lt;semiregular Tag, <i>movable-value</i> Data = <i>see below</i>, sender... Child>
constexpr auto <i>make-sender</i>(Tag, Data&& data, Child&&... child);
Expand Down Expand Up @@ -6407,7 +6414,7 @@ template&lt;class Domain, class Tag, sender Sndr, class... Args>
auto sndr2 = apply(std::move(state.fn), args);
auto rcvr2 = <i>receiver2</i>{std::move(rcvr), std::move(state.env)};
auto mkop2 = [&] { return connect(std::move(sndr2), std::move(rcvr2)); };
auto& op2 = state.ops2.emplace&lt;decltype(mkop2())>(<i>emplacer</i>{mkop2});
auto& op2 = state.ops2.emplace&lt;decltype(mkop2())>(<i>emplace-from</i>{mkop2});
start(op2);
</pre>

Expand Down