Skip to content
Discussion options

You must be logged in to vote

Re: ordering

I finally get what you mean by forked task in a channel, and how it solves the problem of maintaining exact ordering.

As usual there is some weird corner of the language to get this done. https://quuxplusone.github.io/blog/2018/05/17/super-elider-round-2/ lets you construct the non-movable object from the factory function into anything that emplaces. Such as std::optional::emplace, or with std::make_unique. This will let you pass a forked task through a channel.

template <class F> class with_result_of_t {
  F&& fun;

public:
  using T = decltype(std::declval<F&&>()());
  explicit with_result_of_t(F&& f) : fun(std::forward<F>(f)) {}
  operator T() { return fun(); }
};

template <

Replies: 16 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by tzcnt
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #151 on December 09, 2025 02:02.