Created
August 19, 2012 12:40
-
-
Save mindbound/3394644 to your computer and use it in GitHub Desktop.
Turing completeness of C++ templates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
template <int D, int A, typename B> | |
struct K | |
{ | |
static const int x = K<D + 1, 0, K<D, A, B>>::x | |
+ K<D + 1, 1, K<D, A, B>>::x | |
+ K<D + 1, 2, K<D, A, B>>::x | |
+ K<D + 1, 3, K<D, A, B>>::x | |
+ K<D + 1, 4, K<D, A, B>>::x; | |
}; | |
template <int A, typename B> | |
struct K<16, A, B> | |
{ | |
static const int x = 1; | |
}; | |
static const int y = K<0, 0, int>::x; | |
int main() | |
{ | |
printf("%i\n", y); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment