Warning, file /include/range/v3/functional/indirect.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef RANGES_V3_FUNCTIONAL_INDIRECT_HPP
0015 #define RANGES_V3_FUNCTIONAL_INDIRECT_HPP
0016
0017 #include <utility>
0018
0019 #include <concepts/concepts.hpp>
0020
0021 #include <range/v3/functional/invoke.hpp>
0022 #include <range/v3/iterator/traits.hpp>
0023 #include <range/v3/utility/move.hpp>
0024 #include <range/v3/utility/static_const.hpp>
0025
0026 #include <range/v3/detail/prologue.hpp>
0027
0028 namespace ranges
0029 {
0030
0031
0032 template<typename Fn>
0033 struct indirected
0034 {
0035 private:
0036 RANGES_NO_UNIQUE_ADDRESS
0037 Fn fn_;
0038
0039 public:
0040 indirected() = default;
0041 indirected(Fn fn)
0042 : fn_(std::move(fn))
0043 {}
0044
0045 template<typename... Its>
0046 [[noreturn]] invoke_result_t<Fn &, iter_reference_t<Its>...>
0047 operator()(copy_tag, Its...) const
0048 {
0049 RANGES_EXPECT(false);
0050 }
0051
0052
0053
0054 template<typename... Its>
0055 auto CPP_auto_fun(operator())(Its... its)
0056 (
0057 return invoke(fn_, *its...)
0058 )
0059 template<typename... Its>
0060 auto CPP_auto_fun(operator())(Its... its)(const)
0061 (
0062 return invoke((Fn const &)fn_, *its...)
0063 )
0064
0065
0066 template<typename... Its>
0067 auto CPP_auto_fun(operator())(move_tag, Its... its)
0068 (
0069 return static_cast<
0070 aux::move_t<invoke_result_t<Fn &, iter_reference_t<Its>...>>>(
0071 aux::move(invoke(fn_, *its...)))
0072 )
0073 template<typename... Its>
0074 auto CPP_auto_fun(operator())(move_tag, Its... its)(const)
0075 (
0076 return static_cast<
0077 aux::move_t<invoke_result_t<Fn const &, iter_reference_t<Its>...>>>(
0078 aux::move(invoke((Fn const &)fn_, *its...)))
0079 )
0080
0081 };
0082
0083 struct indirect_fn
0084 {
0085 template<typename Fn>
0086 constexpr indirected<Fn> operator()(Fn fn) const
0087 {
0088 return indirected<Fn>{detail::move(fn)};
0089 }
0090 };
0091
0092
0093
0094 RANGES_INLINE_VARIABLE(indirect_fn, indirect)
0095
0096 }
0097
0098 #include <range/v3/detail/epilogue.hpp>
0099
0100 #endif