Skip to content

Instantly share code, notes, and snippets.

@ecatmur
Created November 1, 2012 23:21
Show Gist options
  • Save ecatmur/3997437 to your computer and use it in GitHub Desktop.
Save ecatmur/3997437 to your computer and use it in GitHub Desktop.
#include <iostream>
template<char>struct k;template<>struct k<2>{static
constexpr char t[]=".....\n";};template<>struct k<4>{static
constexpr char t[]=" ";};template<>struct k<8>{static
constexpr char t[]=".abcde";};template<>struct k<9>{static
constexpr char t[]=".jklmnopqr";};template<>struct k<0xc>{static
constexpr char t[]="{ABCDEFGH";};template<>struct k<0xe>{static
constexpr char t[]="\\.STUVW";};constexpr int h(char c){return
c=='a'?0xa:c=='b'?0xb:c=='c'?0xc:c=='d'?0xd:c=='e'?0xe:c=='f'?0xf:c-'0';}template<char
c,char d>struct a{constexpr static
char l=k<h(c)>::t[h(d)];};template<char...>struct
x;template<char c,char d,char...s>struct
x<c,d,s...>{static std::ostream&f(std::ostream&o){return
x<s...>::f(x<c,d>::f(o));}};template<char c,char d>struct
x<c,d>{static std::ostream&f(std::ostream&o){return
o.put(a<c,d>::l);}};template<char,char,char...s>struct
y{typedef x<s...>t;};template<char...s>constexpr std::ostream&(*operator""
_o())(std::ostream&){return y<s...>::t::f;}int
main(){std::cout<<0xc88593939640e69699938425_o;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment