We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- C++
- Other Concepts
- C++ Variadics
- Discussions
C++ Variadics
C++ Variadics
Sort by
recency
|
130 Discussions
|
Please Login in order to post a comment
This is a stupid example, doesn't make any sense
Decided to play with MetaProgramming,
template struct constexpr_pow { constexpr static uint64_t value() { return base * constexpr_pow::value(); } };
template struct constexpr_pow { constexpr static uint64_t value() { return 1; } }; static_assert(constexpr_pow<2, 0>::value() == 1, "Failed pow(2,0)"); static_assert(constexpr_pow<2, 1>::value() == 2, "Failed pow(2,1)"); template constexpr uint64_t reversed_binary_value_impl() { return 0; } // 0, 0, [1...] template constexpr uint64_t reversed_binary_value_impl() { return digit * constexpr_pow<2, n>::value() + reversed_binary_value_impl(); } template constexpr uint64_t reversed_binary_value() { return reversed_binary_value_impl<0, digits...>(); } static_assert(reversed_binary_value<0>() == 0, "Failed 0b0"); static_assert(reversed_binary_value<1>() == 1, "Failed 0b1");