#include using namespace std; constexpr char to_char(unsigned x) { return x % 10 + '0'; } template constexpr char to_chars[] = {to_char(digits)..., '\0'}; template constexpr string_view explode = explode; template constexpr string_view explode<0, digits...> = {to_chars}; template constexpr string_view string_of = explode; constexpr bool can_divide(unsigned x, unsigned y) { return x % y == 0; } constexpr bool contains(string_view x, char m) { return x.find(m) != x.npos; } template constexpr bool can_divide_or_contains = can_divide(x, y) || contains(string_of, to_char(y)); template constexpr string_view fizzbuzz_of_impl = string_of; template constexpr string_view fizzbuzz_of_impl = "Fizz"; template constexpr string_view fizzbuzz_of_impl = "Buzz"; template constexpr string_view fizzbuzz_of_impl = "FizzBuzz"; template constexpr string_view fizzbuzz_of = fizzbuzz_of_impl, can_divide_or_contains>; int main() { static_assert(fizzbuzz_of<1> == "1"); static_assert(fizzbuzz_of<3> == "Fizz"); static_assert(fizzbuzz_of<5> == "Buzz"); static_assert(fizzbuzz_of<15> == "FizzBuzz"); static_assert(fizzbuzz_of<2> == "2"); static_assert(fizzbuzz_of<51> == "FizzBuzz"); }