-
Notifications
You must be signed in to change notification settings - Fork 0
/
fizzbuzz.h
35 lines (27 loc) · 997 Bytes
/
fizzbuzz.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdio.h>
#include <memory.h>
#include <iostream>
#include <typeinfo>
#include <string>
#include <type_traits>
#include <cstdint>
#include "hdeb.h"
#include "racket.h"
struct Fizz { inline static const char value[] = "Fizz"; };
struct Buzz { inline static const char value[] = "Buzz"; };
struct FizzBuzz { inline static const char value[] = "FizzBuzz"; };
template<class N, bool fizz = !(N::value % 3), bool buzz = !(N::value % 5)>
struct fizzbuzz_impl { using type = N; };
template<int_t N>
struct fizzbuzz_impl<int_<N>, true, false> { using type = Fizz; };
template<int_t N>
struct fizzbuzz_impl<int_<N>, false, true> { using type = Buzz; };
template<int_t N>
struct fizzbuzz_impl<int_<N>, true, true> { using type = FizzBuzz; };
template<class N>
using fizzbuzz = fizzbuzz_impl<N>;
void run() {
using input = static_range<int_, 1, 100>::type;
using fizzbuzz_list = static_map<fizzbuzz, input>::type;
static_for_each<fizzbuzz_list>{}.execute(afficher_valeur{ std::cout });
}