48 template <
size_t param_index,
size_t grid_size,
typename EvalResult,
typename Tuple,
typename... TupleTypes>
57 template <
size_t grid_size,
typename EvalResult,
typename Tuple,
typename... TupleTypes>
58 struct Looper<grid_size, grid_size, EvalResult, Tuple, TupleTypes...>
60 template <
typename Functor>
61 double operator()(
const Tuple&, Functor functor, EvalResult , std::array<size_t, grid_size>& )
71 template <
size_t param_index,
size_t grid_size,
typename EvalResult,
typename Tuple,
typename FirstTupleType,
typename... TupleTypes>
72 struct Looper<param_index, grid_size, EvalResult, Tuple, FirstTupleType, TupleTypes...>
74 template <
typename Functor>
75 EvalResult operator()(
const Tuple& grid, Functor functor, EvalResult bestValue, std::array<size_t, grid_size>& bestIndices)
77 for (
size_t index = 0; index < std::get<param_index>(grid).size(); ++index)
79 double currVal = Looper<param_index + 1, grid_size, EvalResult, Tuple, TupleTypes...>()
82 [&grid, index, &functor](TupleTypes... rest){
return functor(std::get<param_index>(grid)[index], rest...);},
87 if ( currVal > bestValue )
90 bestIndices[param_index] = index;
98 template <
typename... TupleTypes>
103 grid_(std::make_tuple<std::vector<TupleTypes>...>(std::move(gridValues)...))
107 template <
typename Functor>
108 typename std::result_of<Functor(TupleTypes...)>::type
evaluate(Functor evaluator,
109 typename std::result_of<Functor(TupleTypes...)>::type startValue,
110 std::array<
size_t,std::tuple_size<std::tuple<std::vector<TupleTypes>...>>::value>& resultIndices)
112 return Internal::Looper<0,
113 std::tuple_size<std::tuple<std::vector<TupleTypes>...>>::value,
114 typename std::result_of<Functor(TupleTypes...)>::type,
115 std::tuple<std::vector<TupleTypes>...>,
117 (
grid_, evaluator, startValue, resultIndices);
122 template <
typename EvalResult>
123 EvalResult
evaluate(EvalResult evaluator(TupleTypes...),
124 EvalResult startValue,
125 std::array<
size_t,std::tuple_size<std::tuple<std::vector<TupleTypes>...>>::value>& resultIndices)
127 return Internal::Looper<0,
128 std::tuple_size<std::tuple<std::vector<TupleTypes>...>>::value,
130 std::tuple<std::vector<TupleTypes>...>,
132 (
grid_, evaluator, startValue, resultIndices);
149 std::tuple<std::vector<TupleTypes>...>
grid_;
153 template<std::
size_t I = 0>
154 typename std::enable_if<I ==
sizeof...(TupleTypes),
unsigned int>::type
161 template<std::
size_t I = 0>
162 typename std::enable_if<I <
sizeof...(TupleTypes),
unsigned int>::type
166 return nrCombos<I + 1>();