Created
July 2, 2020 22:23
-
-
Save iitalics/83ad70b5d4bdba428145f20bf8bcdc2b to your computer and use it in GitHub Desktop.
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 <stdio.h> | |
template <int N> struct fizz { enum { flags = 0 }; }; | |
template<> struct fizz<0> { enum { flags = 1 }; }; | |
template <int N> struct buzz { enum { flags = 0 }; }; | |
template<> struct buzz<0> { enum { flags = 2 }; }; | |
template <int F, int N> struct show { show() { printf("%d\n", N); } }; | |
template <int N> struct show<1, N> { show() { printf("Fizz\n"); } }; | |
template <int N> struct show<2, N> { show() { printf("Buzz\n"); } }; | |
template <int N> struct show<3, N> { show() { printf("FizzBuzz\n"); } }; | |
template <int N> | |
struct loop { | |
show<(fizz<N % 3>::flags | buzz<N % 5>::flags), N> s; | |
loop<(N + 1)> l; | |
}; | |
template <> | |
struct loop<101> {}; | |
loop<1> l; | |
int main(void) {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment