/* * Copyright (c) Facebook, Inc. and its affiliates. * * Licensed under the Apache License Version 2.0 with LLVM Exceptions * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * https://llvm.org/LICENSE.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include #include #include #include #include #include namespace unifex { namespace _with_query_value { template struct _receiver_wrapper { class type; }; template using receiver_wrapper = typename _receiver_wrapper::type; template class _receiver_wrapper::type { public: template explicit type(Receiver2 &&receiver, const Value& val) : receiver_((Receiver2 &&) receiver) , val_(&val) {} private: friend const Value &tag_invoke(CPO, const type &r) noexcept { return *r.val_; } template(typename OtherCPO, typename Self, typename... Args) (requires same_as, type> AND callable, Args...>) friend auto tag_invoke(OtherCPO cpo, Self&& self, Args&&... args) noexcept(is_nothrow_callable_v, Args...>) -> callable_result_t, Args...> { return static_cast(cpo)(static_cast(self).receiver_, static_cast(args)...); } Receiver receiver_; const Value* val_; }; template struct _op { class type; }; template using operation = typename _op>::type; template class _op::type { public: template explicit type(Sender &&sender, Receiver2 &&receiver, Value2 &&value) : value_((Value2 &&) value) , innerOp_( connect((Sender &&) sender, receiver_wrapper{ (Receiver2 &&) receiver, value_})) {} void start() & noexcept { unifex::start(innerOp_); } private: UNIFEX_NO_UNIQUE_ADDRESS Value value_; /*UNIFEX_NO_UNIQUE_ADDRESS*/ connect_result_t> innerOp_; }; template struct _sender { class type; }; template using sender = typename _sender, remove_cvref_t>::type; template class _sender::type { public: template