Mercurial > lbo > hg > ctmp
view src/binary.cc @ 14:ab9ed41eb455
higherorder: a few exercises
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Fri, 27 Mar 2020 15:09:49 +0100 |
parents | c0219423b5b2 |
children |
line wrap: on
line source
#include <iostream> #include <boost/static_assert.hpp> template<unsigned long In> struct binary { static const unsigned long value = binary<In/10>::value * 2 + In%10; BOOST_STATIC_ASSERT(In%10 < 2); }; template<> struct binary<1> { static const unsigned value = 1; }; int main(void) { std::cout << binary<1101011101>::value << "\n"; return 0; }