00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef CALL_TUPLE_HH
00018 # define CALL_TUPLE_HH
00019
00020 # include <tuple>
00021 # include <type_traits>
00022 # include "../type_traits/is_callable.hh"
00023
00024 namespace catsfoot {
00025 namespace details {
00026 template <typename Parameter, typename... Functions>
00027 struct call_tuple_helper {
00028 typedef
00029 std::tuple<typename std::decay
00030 <typename is_callable
00031 <const Functions(const Parameter&)>::result_type>
00032 ::type...> return_type;
00033
00034 static return_type
00035 call(const std::tuple<Functions...>&,
00036 const Parameter&,
00037 typename is_callable
00038 <const Functions(const Parameter&)>::result_type... args) {
00039 return std::make_tuple(std::move(args)...);
00040 }
00041
00042 template <typename... Args>
00043 static return_type
00044 call(const std::tuple<Functions...>& functions,
00045 const Parameter& param,
00046 Args... args) {
00047 return call
00048 (functions, param,
00049 std::move(args)...,
00050 std::move(std::get<sizeof...(Args)>(functions)(param)));
00051 }
00052 };
00053 }
00054
00060 template <typename Parameter, typename... Functions>
00061 std::tuple<typename std::decay
00062 <typename is_callable
00063 <const Functions(const Parameter&)>::result_type>
00064 ::type...>
00065 call_tuple(const std::tuple<Functions...>& functions,
00066 const Parameter& param) {
00067 return details::call_tuple_helper<Parameter, Functions...>
00068 ::call(functions, param);
00069 }
00070
00071 }
00072
00073 #endif