Created
April 30, 2017 20:01
-
-
Save stryku/986bcd6a5d5773ef0e0136a5eca97e20 to your computer and use it in GitHub Desktop.
This file contains 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
#include <iostream> | |
#include <regex> | |
template<size_t ...values> | |
struct values_container | |
{}; | |
namespace details | |
{ | |
template <typename value_type, typename Is> | |
struct create_impl; | |
template <typename value_type, auto ...tmps> | |
struct create_impl<value_type, std::integer_sequence<size_t, tmps...>> | |
{ | |
using result = values_container<static_cast<value_type>(tmps^tmps)...>; | |
}; | |
} | |
template <typename value_type, size_t size> | |
using create_container = typename details::create_impl<value_type, | |
std::make_index_sequence<size>>::result; | |
template <size_t N> | |
struct add | |
{ | |
using container = create_container<size_t, N>; | |
static constexpr size_t result = add<N-1>::result + N; | |
}; | |
template <> | |
struct add<1> | |
{ | |
static constexpr size_t result = 0; | |
}; | |
int main() | |
{ | |
return add<88888>::result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment