File indexing completed on 2025-01-18 09:38:15
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_HOF_GUARD_COMBINE_H
0009 #define BOOST_HOF_GUARD_COMBINE_H
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057 #include <boost/hof/pack.hpp>
0058 #include <boost/hof/always.hpp>
0059 #include <boost/hof/detail/callable_base.hpp>
0060 #include <boost/hof/detail/make.hpp>
0061
0062 namespace boost { namespace hof { namespace detail {
0063
0064 template<class S, class F, class... Gs>
0065 struct combine_adaptor_base;
0066
0067 template<std::size_t... Ns, class F, class... Gs>
0068 struct combine_adaptor_base<seq<Ns...>, F, Gs...>
0069 : F, pack_base<seq<Ns...>, Gs...>
0070 {
0071 typedef pack_base<seq<Ns...>, Gs...> base_type;
0072
0073 BOOST_HOF_INHERIT_DEFAULT(combine_adaptor_base, base_type, F)
0074
0075 template<class X, class... Xs,
0076 BOOST_HOF_ENABLE_IF_CONSTRUCTIBLE(F, X),
0077 BOOST_HOF_ENABLE_IF_CONSTRUCTIBLE(base_type, Xs...)>
0078 constexpr combine_adaptor_base(X&& x, Xs&&... xs)
0079 : F(BOOST_HOF_FORWARD(X)(x)), base_type(BOOST_HOF_FORWARD(Xs)(xs)...)
0080 {}
0081
0082 template<class... Ts>
0083 constexpr const F& base_function(Ts&&... xs) const
0084 {
0085 return boost::hof::always_ref(*this)(xs...);
0086 }
0087
0088 BOOST_HOF_RETURNS_CLASS(combine_adaptor_base);
0089
0090
0091
0092 #if BOOST_HOF_NO_EXPRESSION_SFINAE || BOOST_HOF_HAS_MANUAL_DEDUCTION
0093 template<class... Ts>
0094 struct combine_result
0095 : result_of<const F&, result_of<const Gs&, id_<Ts>>...>
0096 {};
0097 #endif
0098
0099 template<class... Ts>
0100 #if BOOST_HOF_NO_EXPRESSION_SFINAE || BOOST_HOF_HAS_MANUAL_DEDUCTION
0101 constexpr typename combine_result<Ts...>::type
0102 #else
0103 constexpr auto
0104 #endif
0105 operator()(Ts&&... xs) const BOOST_HOF_SFINAE_MANUAL_RETURNS
0106 (
0107 (BOOST_HOF_MANGLE_CAST(const F&)(BOOST_HOF_CONST_THIS->base_function(xs...)))
0108 (boost::hof::alias_value<pack_tag<seq<Ns>, Gs...>, Gs>(*BOOST_HOF_CONST_THIS, xs)(BOOST_HOF_FORWARD(Ts)(xs))...)
0109 );
0110 };
0111
0112 }
0113
0114 template<class F, class... Gs>
0115 struct combine_adaptor
0116 : detail::combine_adaptor_base<typename detail::gens<sizeof...(Gs)>::type, detail::callable_base<F>, detail::callable_base<Gs>...>
0117 {
0118 typedef detail::combine_adaptor_base<typename detail::gens<sizeof...(Gs)>::type, detail::callable_base<F>, detail::callable_base<Gs>...> base_type;
0119 BOOST_HOF_INHERIT_CONSTRUCTOR(combine_adaptor, base_type)
0120 };
0121
0122 BOOST_HOF_DECLARE_STATIC_VAR(combine, detail::make<combine_adaptor>);
0123
0124 }}
0125
0126 #endif