15 #ifndef ROOT7_Impl_Tuple_Apply 16 #define ROOT7_Impl_Tuple_Apply 18 #include "RConfigure.h" 27 inline namespace __ROOT {
29 #ifndef R__HAS_STD_INVOKE 31 template <
class F,
class... Args>
32 inline auto INVOKE(
F&& f, Args&&... args) ->
33 decltype(std::forward<F>(f)(std::forward<Args>(args)...)) {
34 return std::forward<F>(f)(std::forward<Args>(args)...);
37 template <
class Base,
class T,
class Derived>
38 inline auto INVOKE(
T Base::*pmd, Derived&& ref) ->
39 decltype(std::forward<Derived>(ref).*pmd) {
40 return std::forward<Derived>(ref).*pmd;
43 template <
class PMD,
class Po
inter>
44 inline auto INVOKE(PMD pmd, Pointer&& ptr) ->
45 decltype((*std::forward<Pointer>(ptr)).*pmd) {
46 return (*std::forward<Pointer>(ptr)).*pmd;
49 template <
class Base,
class T,
class Derived,
class... Args>
50 inline auto INVOKE(T Base::*pmf, Derived&& ref, Args&&... args) ->
51 decltype((std::forward<Derived>(ref).*pmf)(std::forward<Args>(args)...)) {
52 return (std::forward<Derived>(ref).*pmf)(std::forward<Args>(args)...);
55 template <
class PMF,
class Pointer,
class... Args>
56 inline auto INVOKE(PMF pmf, Pointer&& ptr, Args&&... args) ->
57 decltype(((*std::forward<Pointer>(ptr)).*pmf)(std::forward<Args>(args)...)) {
58 return ((*std::forward<Pointer>(ptr)).*pmf)(std::forward<Args>(args)...);
62 template<
class F,
class... ArgTypes>
63 decltype(
auto)
invoke(
F&& f, ArgTypes&&... args) {
64 return detail::INVOKE(std::forward<F>(f), std::forward<ArgTypes>(args)...);
66 #endif // ndef R__HAS_STD_INVOKE 68 #ifndef R__HAS_STD_APPLY 71 template<
class F,
class Tuple, std::size_t...
I>
73 std::index_sequence<
I...>) {
74 return invoke(std::forward<F>(f),
75 std::get<I>(std::forward<Tuple>(t))...);
80 template<
class F,
class Tuple>
81 constexpr decltype(
auto)
apply(
F &&f, Tuple &&t) {
83 std::make_index_sequence < std::tuple_size <
84 std::decay_t < Tuple >> {} > {});
86 #endif // ndef R__HAS_STD_APPLY 90 #endif //ROOT7_TUPLE_APPLY_H
auto INVOKE(F &&f, Args &&... args) -> decltype(std::forward< F >(f)(std::forward< Args >(args)...))
decltype(auto) invoke(F &&f, ArgTypes &&... args)
decltype(auto) constexpr apply_impl(F &&f, Tuple &&t, std::index_sequence< I... >)
decltype(auto) constexpr apply(F &&f, Tuple &&t)