All Classes Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
gears::meta::build_indices< N, Ns > Struct Template Reference

Creates an index sequence. More...

Detailed Description

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;
// turns f(std::tuple<Args...>) to f(Args...)
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)>{})) {
return 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
NLength of the index.

Definition at line 86 of file indices.hpp.