I'm asked to produce a template that can handle the digits... pack of binary and return the corresponding integer. However, I'm curious as to how the following code produces a binary pack. The only input I see is a 6. I can figure that 2^6 being 64 is related to the pack being 64 bits but how is it actually produced?
The following may also be relevant
The input may look something like this
2
65 1
10 0
The code is as follows
template <int n, bool...digits>
struct CheckValues {
static void check(int x, int y)
{
CheckValues<n-1, 0, digits...>::check(x, y);
CheckValues<n-1, 1, digits...>::check(x, y);
}
};
template <bool...digits>
struct CheckValues<0, digits...> {
static void check(int x, int y)
{
int z = reversed_binary_value<digits...>();
std::cout << (z+64*y==x);
}
};
int main()
{
int t; std::cin >> t;
for (int i=0; i!=t; ++i) {
int x, y;
cin >> x >> y;
CheckValues<6>::check(x, y);
cout << "\n";
}
}