Skip to content

Instantly share code, notes, and snippets.

@iitalics
Created July 2, 2020 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iitalics/83ad70b5d4bdba428145f20bf8bcdc2b to your computer and use it in GitHub Desktop.
Save iitalics/83ad70b5d4bdba428145f20bf8bcdc2b to your computer and use it in GitHub Desktop.
#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