Skip to content

Instantly share code, notes, and snippets.

@njlr
Created May 31, 2017 15:02
Show Gist options
  • Save njlr/691d9862fc7af5a02791e5dc3cdb2536 to your computer and use it in GitHub Desktop.
Save njlr/691d9862fc7af5a02791e5dc3cdb2536 to your computer and use it in GitHub Desktop.
template<unsigned n>
struct Get {
template<class X, class…Xs>
constexpr auto operator()(X x, Xs…xs) {
if constexpr(n > sizeof…(xs) ) {
return;
} else if constexpr(n > 0) {
return Get<n-1>{}(xs…);
} else {
return x;
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment