libfilezilla
apply.hpp
Go to the documentation of this file.
1 #ifndef LIBFILEZILLA_APPLY_HEADER
2 #define LIBFILEZILLA_APPLY_HEADER
3 
4 #include <cstddef>
5 #include <utility>
6 #include <tuple>
7 #include <type_traits>
8 
17 namespace fz {
18 
22 template<typename Obj, typename F, typename Tuple, size_t... I>
23 auto apply_(Obj&& obj, F&& f, Tuple&& t, std::index_sequence<I...> const&) -> decltype((std::forward<Obj>(obj)->*std::forward<F>(f))(std::get<I>(std::forward<Tuple>(t))...))
24 {
25  return (std::forward<Obj>(obj)->*std::forward<F>(f))(std::get<I>(std::forward<Tuple>(t))...);
26 }
27 
47 template<typename Obj, typename F, typename Tuple, typename Seq = typename std::make_index_sequence<std::tuple_size_v<typename std::remove_reference_t<Tuple>>>>
48 auto apply(Obj&& obj, F && f, Tuple&& args) -> decltype(apply_(std::forward<Obj>(obj), std::forward<F>(f), std::forward<Tuple>(args), Seq()))
49 {
50  return apply_(std::forward<Obj>(obj), std::forward<F>(f), std::forward<Tuple>(args), Seq());
51 }
52 
53 }
54 
55 #endif
The namespace used by libfilezilla.
Definition: apply.hpp:17
auto apply(Obj &&obj, F &&f, Tuple &&args) -> decltype(apply_(std::forward< Obj >(obj), std::forward< F >(f), std::forward< Tuple >(args), Seq()))
Apply tuple to pointer to member.
Definition: apply.hpp:48