template<size_t N, size_t... Ns>
struct gears::meta::build_indices< N, Ns >
Creates an index sequence. build_indices<N>
would create indices<0, 1, 2, ..., N - 1>
.
Example:
#include <gears/meta/indices.hpp>
#include <gears/adl/get.hpp>
#include <tuple>
#include <iostream>
using namespace gears::meta;
namespace adl = gears::adl;
template<typename Function, typename... Args, size_t... Indices>
auto apply(Function f,
const std::tuple<Args...>& t,
indices<Indices...>) -> decltype(f(adl::get<Indices>(t)...)) {
return f(adl::get<Indices>(t)...);
}
template<typename Function, typename... Args>
auto apply(Function f,
const std::tuple<Args...>& t) -> decltype(apply(f, t,
build_indices<
sizeof...(Args)>{})) {
}
int f(int x, int y, int z) {
return x + y + z;
}
int main() {
auto args = std::make_tuple(10, 11, 12);
std::cout << apply(f, args);
}
Output:
33
- Template Parameters
-
Definition at line 86 of file indices.hpp.