Skip to content

Instantly share code, notes, and snippets.

@gwy15
Created October 26, 2018 20:31
Show Gist options
  • Save gwy15/5a664ccf8b687ccc89c04e924fc98aef to your computer and use it in GitHub Desktop.
Save gwy15/5a664ccf8b687ccc89c04e924fc98aef to your computer and use it in GitHub Desktop.
template compile OTM
#include <iostream>
#include <tuple>
template <int n> auto foo(int a) {
return std::make_tuple(foo<n - 1>(a), foo<n - 1>(a));
}
template <> auto foo<0>(int a) { return std::make_tuple(a, a); }
int main() {
auto i = foo<100>(2);
std::cout << &i << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment