Skip to content

Instantly share code, notes, and snippets.

@cjsmeele
Last active March 14, 2018 09:05
Show Gist options
  • Save cjsmeele/12759a016b6a5284ae5e7bdf17853b90 to your computer and use it in GitHub Desktop.
Save cjsmeele/12759a016b6a5284ae5e7bdf17853b90 to your computer and use it in GitHub Desktop.
MPL Fizzbuzz
#include <mpl/mpl.hpp>
using namespace kvasir::mpl;
struct fizz{};
struct buzz{};
struct fizzbuzz{};
template<typename C = identity>
using fizzbuzzed = make_int_sequence<
if_<push_back<uint_<3>,
modulo<logical_not<>>>,
if_<push_back<uint_<5>,
modulo<logical_not<>>>,
always<fizzbuzz>,
always<fizz>>,
if_<push_back<uint_<5>,
modulo<logical_not<>>>,
always<buzz>,
identity>>>;
list<fizzbuzz,
uint_<1>,
uint_<2>,
fizz,
uint_<4>,
buzz,
fizz,
uint_<7>,
uint_<8>,
fizz,
buzz,
uint_<11>,
fizz,
uint_<13>,
uint_<14>,
fizzbuzz,
uint_<16>,
uint_<17>,
fizz,
uint_<19>> x = call<fizzbuzzed<>,int_<20>> { };
int main() {
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment