Skip to content

Instantly share code, notes, and snippets.

@stryku
Created April 30, 2017 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stryku/986bcd6a5d5773ef0e0136a5eca97e20 to your computer and use it in GitHub Desktop.
Save stryku/986bcd6a5d5773ef0e0136a5eca97e20 to your computer and use it in GitHub Desktop.
#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