File indexing completed on 2025-12-16 10:27:57
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef RANGES_V3_FUNCTIONAL_ON_HPP
0014 #define RANGES_V3_FUNCTIONAL_ON_HPP
0015
0016 #include <concepts/concepts.hpp>
0017
0018 #include <range/v3/detail/config.hpp>
0019 #include <range/v3/functional/invoke.hpp>
0020
0021 #include <range/v3/detail/prologue.hpp>
0022
0023 namespace ranges
0024 {
0025
0026
0027 template<typename Fn1, typename Fn2>
0028 struct transformed
0029 {
0030 private:
0031 RANGES_NO_UNIQUE_ADDRESS
0032 Fn1 first_;
0033 RANGES_NO_UNIQUE_ADDRESS
0034 Fn2 second_;
0035
0036 public:
0037 transformed() = default;
0038 constexpr transformed(Fn1 fn1, Fn2 fn2)
0039 : first_(static_cast<Fn1 &&>(fn1))
0040 , second_(static_cast<Fn2 &&>(fn2))
0041 {}
0042
0043 template<typename... Args>
0044 auto CPP_auto_fun(operator())(Args &&... args)
0045 (
0046 return invoke(first_, invoke(second_, static_cast<Args &&>(args)...))
0047 )
0048 template<typename... Args>
0049 auto CPP_auto_fun(operator())(Args &&... args)(const)
0050 (
0051 return invoke((Fn1 const &)first_,
0052 invoke((Fn2 const &)second_, static_cast<Args &&>(args))...)
0053 )
0054
0055 };
0056
0057 struct on_fn
0058 {
0059 template<typename Fn1, typename Fn2>
0060 constexpr transformed<Fn1, Fn2> operator()(Fn1 fn1, Fn2 fn2) const
0061 {
0062 return transformed<Fn1, Fn2>{detail::move(fn1), detail::move(fn2)};
0063 }
0064 };
0065
0066
0067
0068 RANGES_INLINE_VARIABLE(on_fn, on)
0069
0070 }
0071
0072 #include <range/v3/detail/epilogue.hpp>
0073
0074 #endif