In this HackerRank C++ Variadics problem in c++ you need to create a template function named reversed_binary_value. It must take an arbitrary number of bool values as template parameters. These booleans represent binary digits in reverse order. Your function must return an integer corresponding to the binary value of the digits represented by the booleans. For example: reversed_binary_value<0,0,1>() should return 4.

HackerRank C++ Variadics problem solution

HackerRank C++ Variadics problem solution

// Enter your code for reversed_binary_value<bool...>()
template<bool...digits> struct count;

struct count<> {
static constexpr int value = 0;

template<bool b, bool...digits>
struct count<b, digits...> {
static constexpr int value = b + 2 * count<digits...>::value;

template <bool...digits>
constexpr int reversed_binary_value ()
    return count<digits...>::value;