Mercurial > lbo > hg > ctmp
view src/binary.cc @ 0:c0219423b5b2
Add binary example (p. 4)
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Mon, 23 Mar 2020 18:29:46 +0100 |
parents | |
children | ab9ed41eb455 |
line wrap: on
line source
#include <iostream> template<unsigned long In> struct binary { static const unsigned long value = binary<In/10>::value * 2 + In%10; }; template<> struct binary<1> { static const unsigned value = 1; }; int main(void) { std::cout << binary<1101011101>::value << "\n"; return 0; }