File indexing completed on 2025-01-30 09:43:50
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_HOF_GUARD_FUNCTION_INDIRECT_H
0009 #define BOOST_HOF_GUARD_FUNCTION_INDIRECT_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
0058
0059
0060
0061 #include <boost/hof/detail/delegate.hpp>
0062 #include <boost/hof/detail/result_of.hpp>
0063 #include <boost/hof/reveal.hpp>
0064 #include <boost/hof/always.hpp>
0065 #include <boost/hof/detail/move.hpp>
0066 #include <boost/hof/detail/make.hpp>
0067 #include <boost/hof/detail/static_const_var.hpp>
0068
0069 namespace boost { namespace hof {
0070
0071 template<class F>
0072 struct indirect_adaptor : F
0073 {
0074 typedef indirect_adaptor fit_rewritable1_tag;
0075 BOOST_HOF_INHERIT_CONSTRUCTOR(indirect_adaptor, F);
0076
0077 template<class... Ts>
0078 constexpr const F& base_function(Ts&&... xs) const noexcept
0079 {
0080 return boost::hof::always_ref(*this)(xs...);
0081 }
0082
0083 struct failure
0084 : failure_for<decltype(*std::declval<F>())>
0085 {};
0086
0087 BOOST_HOF_RETURNS_CLASS(indirect_adaptor);
0088
0089 template<class... Ts>
0090 constexpr BOOST_HOF_SFINAE_RESULT(decltype(*std::declval<F>()), id_<Ts>...)
0091 operator()(Ts&&... xs) const BOOST_HOF_SFINAE_RETURNS
0092 (
0093 (*BOOST_HOF_MANGLE_CAST(const F&)(BOOST_HOF_CONST_THIS->base_function(xs...)))(BOOST_HOF_FORWARD(Ts)(xs)...)
0094 );
0095 };
0096
0097 template<class F>
0098 struct indirect_adaptor<F*>
0099 {
0100 typedef indirect_adaptor fit_rewritable1_tag;
0101 F* f;
0102 constexpr indirect_adaptor() noexcept
0103 {}
0104
0105 constexpr indirect_adaptor(F* x) noexcept
0106 : f(x)
0107 {}
0108
0109 template<class... Ts>
0110 constexpr F& base_function(Ts&&...) const noexcept
0111 {
0112 return *f;
0113 }
0114
0115 struct failure
0116 : failure_for<F>
0117 {};
0118
0119 BOOST_HOF_RETURNS_CLASS(indirect_adaptor);
0120
0121 template<class... Ts>
0122 constexpr BOOST_HOF_SFINAE_RESULT(F, id_<Ts>...)
0123 operator()(Ts&&... xs) const BOOST_HOF_SFINAE_RETURNS
0124 (
0125 (BOOST_HOF_MANGLE_CAST(F&)(BOOST_HOF_CONST_THIS->base_function(xs...)))(BOOST_HOF_FORWARD(Ts)(xs)...)
0126 );
0127 };
0128
0129 BOOST_HOF_DECLARE_STATIC_VAR(indirect, detail::make<indirect_adaptor>);
0130
0131 }}
0132
0133 #endif