// Copyright (c) OpenMMLab. All rights reserved. // Modified from // https://github.com/brycelelbach/wg21_p2300_std_execution/blob/main/include/execution.hpp #ifndef MMDEPLOY_CSRC_EXPERIMENTAL_EXECUTION_JUST_H_ #define MMDEPLOY_CSRC_EXPERIMENTAL_EXECUTION_JUST_H_ #include #include "concepts.h" #include "utility.h" namespace mmdeploy { namespace __just { template struct _Operation { struct type; }; template using operation_t = typename _Operation, Ts...>::type; template struct _Operation::type { std::tuple values_; Receiver receiver_; friend void tag_invoke(start_t, type& op_state) noexcept { std::apply( [&](Ts&... ts) -> void { SetValue(std::move(op_state.receiver_), std::move(ts)...); }, op_state.values_); } }; template struct _Sender { struct type; }; template using sender_t = typename _Sender...>::type; template struct _Sender::type { using value_types = std::tuple; value_types values_; template friend operation_t tag_invoke(connect_t, const type& self, Receiver&& receiver) { return {self.values_, (Receiver &&) receiver}; } template friend operation_t tag_invoke(connect_t, type&& self, Receiver&& receiver) { return {std::move(self).values_, (Receiver &&) receiver}; } }; struct just_t { template sender_t operator()(Ts&&... ts) const { return {{(Ts &&) ts...}}; } }; } // namespace __just using __just::just_t; inline constexpr just_t Just{}; } // namespace mmdeploy #endif // MMDEPLOY_CSRC_EXPERIMENTAL_EXECUTION_JUST_H_