#pragma once /* * Copyright 2018-present Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * 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. */ #include #include #include #include namespace pushmi { template class any_time_single_sender : public any_constrained_single_sender { public: using properties = property_set, is_single<>>; constexpr any_time_single_sender() = default; template constexpr explicit any_time_single_sender(T t) : any_constrained_single_sender(std::move(t)) {} template constexpr any_time_single_sender(T0 t0, T1 t1, TN... tn) : any_constrained_single_sender( std::move(t0), std::move(t1), std::move(tn)...) {} any_time_executor executor() { return any_time_executor{ any_constrained_single_sender::executor()}; } }; template class time_single_sender : public constrained_single_sender { public: using properties = property_set, is_single<>>; constexpr time_single_sender() = default; template constexpr explicit time_single_sender(T t) : constrained_single_sender(std::move(t)) {} template constexpr time_single_sender(T0 t0, T1 t1, TN... tn) : constrained_single_sender( std::move(t0), std::move(t1), std::move(tn)...) {} }; template class time_single_sender : public constrained_single_sender { public: constexpr time_single_sender() = default; template constexpr explicit time_single_sender(T t) : constrained_single_sender(std::move(t)) {} template constexpr time_single_sender(C0 c0, C1 c1, CN... cn) : constrained_single_sender( std::move(c0), std::move(c1), std::move(cn)...) {} }; template <> class time_single_sender<> : public time_single_sender { public: time_single_sender() = default; }; //////////////////////////////////////////////////////////////////////////////// // make_time_single_sender PUSHMI_INLINE_VAR constexpr struct make_time_single_sender_fn { inline auto operator()() const { return time_single_sender{}; } PUSHMI_TEMPLATE(class SF) (requires True<> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender)) auto operator()(SF sf) const { return time_single_sender{std::move(sf)}; } PUSHMI_TEMPLATE (class SF, class EXF) (requires Invocable PUSHMI_BROKEN_SUBSUMPTION(&& not Sender)) auto operator()(SF sf, EXF exf) const { return time_single_sender{ std::move(sf), std::move(exf)}; } PUSHMI_TEMPLATE (class SF, class NF, class EXF) (requires Invocable && Invocable PUSHMI_BROKEN_SUBSUMPTION(&& not Sender)) auto operator()(SF sf, EXF exf, NF nf) const { return time_single_sender{ std::move(sf), std::move(exf), std::move(nf)}; } PUSHMI_TEMPLATE (class Data) (requires TimeSender>) auto operator()(Data d) const { return time_single_sender{std::move(d)}; } PUSHMI_TEMPLATE (class Data, class DSF) (requires TimeSender>) auto operator()(Data d, DSF sf) const { return time_single_sender{ std::move(d), std::move(sf)}; } PUSHMI_TEMPLATE (class Data, class DSF, class DEXF) (requires TimeSender> && Invocable) auto operator()(Data d, DSF sf, DEXF exf) const { return time_single_sender{ std::move(d), std::move(sf), std::move(exf)}; } PUSHMI_TEMPLATE (class Data, class DSF, class DNF, class DEXF) (requires TimeSender> && Invocable && Invocable) auto operator()(Data d, DSF sf, DEXF exf, DNF nf) const { return time_single_sender{ std::move(d), std::move(sf), std::move(exf), std::move(nf)}; } } const make_time_single_sender {}; //////////////////////////////////////////////////////////////////////////////// // deduction guides #if __cpp_deduction_guides >= 201703 time_single_sender() -> time_single_sender; PUSHMI_TEMPLATE(class SF) (requires True<> PUSHMI_BROKEN_SUBSUMPTION(&& not Sender)) time_single_sender(SF) -> time_single_sender; PUSHMI_TEMPLATE (class SF, class EXF) (requires Invocable PUSHMI_BROKEN_SUBSUMPTION(&& not Sender)) time_single_sender(SF, EXF) -> time_single_sender; PUSHMI_TEMPLATE (class SF, class NF, class EXF) (requires Invocable && Invocable PUSHMI_BROKEN_SUBSUMPTION(&& not Sender)) time_single_sender(SF, EXF, NF) -> time_single_sender; PUSHMI_TEMPLATE (class Data, class DSF) (requires TimeSender>) time_single_sender(Data, DSF) -> time_single_sender; PUSHMI_TEMPLATE (class Data, class DSF, class DEXF) (requires TimeSender> && Invocable) time_single_sender(Data, DSF, DEXF) -> time_single_sender; PUSHMI_TEMPLATE (class Data, class DSF, class DNF, class DEXF) (requires TimeSender> && Invocable && Invocable) time_single_sender(Data, DSF, DEXF, DNF) -> time_single_sender; #endif template<> struct construct_deduced : make_time_single_sender_fn {}; } //namespace pushmi