Created
February 21, 2017 14:37
-
-
Save udaken/039dbb4e27cfd1546569e6d855371049 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template <int N> | |
| int bin_digit(); | |
| template <> | |
| int bin_digit<0>() | |
| { | |
| return 0; | |
| } | |
| template <> | |
| int bin_digit<1>() | |
| { | |
| return 1; | |
| } | |
| template <int N2, int N1> | |
| int bin_digit() | |
| { | |
| return bin_digit<N2>() << 1 | bin_digit<N1>(); | |
| } | |
| template <int N3, int N2, int N1> | |
| int bin_digit() | |
| { | |
| return bin_digit<N3, N2>() << 1 | bin_digit<N1>(); | |
| } | |
| template <int N4, int N3, int N2, int N1> | |
| int bin_digit() | |
| { | |
| return bin_digit<N4, N3, N2>() << 1 | bin_digit<N1>(); | |
| } | |
| template <int N5, int N4, int N3, int N2, int N1> | |
| int bin_digit() | |
| { | |
| return bin_digit<N5, N4, N3, N2>() << 1 | bin_digit<N1>(); | |
| } | |
| template <int N6, int N5, int N4, int N3, int N2, int N1> | |
| int bin_digit() | |
| { | |
| return bin_digit<N6, N5, N4, N3, N2>() << 1 | bin_digit<N1>(); | |
| } | |
| template <int N7, int N6, int N5, int N4, int N3, int N2, int N1> | |
| int bin_digit() | |
| { | |
| return bin_digit<N7, N6, N5, N4, N3, N2>() << 1 | bin_digit<N1>(); | |
| } | |
| template <int N8, int N7, int N6, int N5, int N4, int N3, int N2, int N1> | |
| int bin_digit() | |
| { | |
| return bin_digit<N8, N7, N6, N5, N4, N3, N2>() << 1 | bin_digit<N1>(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment