Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- template<int N>
- void foo() { std::cout << __PRETTY_FUNCTION__ << '\n'; }
- template <int... Ns>
- decltype(auto) dispatch_foo(int const n, std::integer_sequence<int, Ns...>) {
- static constexpr void (*_foos[])() { &foo<Ns>... };
- return _foos[n]();
- }
- template <int Nmax>
- decltype(auto) dispatch_foo(int const n) {
- return dispatch_foo(n, std::make_integer_sequence<int, Nmax>{});
- }
- int main() {
- dispatch_foo<10>(3);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement