variadic: use make_index_sequence from the stdlib

This commit is contained in:
Danny Robson 2017-06-07 16:31:55 +10:00
parent 2bc7e3e449
commit e019270a1f
4 changed files with 14 additions and 56 deletions

View File

@ -25,6 +25,7 @@
#include <cstdint>
#include <string>
#include <tuple>
#include <utility>
#include <experimental/filesystem>
@ -360,11 +361,11 @@ namespace util {
template <
typename K,
typename I = typename make_indices<
typename I = typename std::make_index_sequence<
std::tuple_size<
typename type<K>::fields
>::value
>::type
>
> struct _type_tuple;
template <
@ -372,7 +373,7 @@ namespace util {
size_t ...I
> struct _type_tuple <
K,
indices<I...>
std::index_sequence<I...>
> {
typedef std::tuple<
typename std::tuple_element<
@ -394,11 +395,11 @@ namespace util {
namespace detail {
template <
typename K,
typename I = typename make_indices<
typename I = typename std::make_index_sequence<
std::tuple_size<
typename type<K>::fields
>::value
>::type
>
>
struct _as_tuple;
@ -408,7 +409,7 @@ namespace util {
>
struct _as_tuple <
K,
indices<I...>
std::index_sequence<I...>
>
{
static typename type_tuple<K>::type

View File

@ -74,7 +74,7 @@ namespace util::tuple {
size_t ...I
>
auto
call (const Func &func, std::tuple<Args...> args, indices<I...>)
call (const Func &func, std::tuple<Args...> args, std::index_sequence<I...>)
{
// quiet unused variable warning with zero args
(void)args;
@ -91,7 +91,7 @@ namespace util::tuple {
auto
call (const Func &func, std::tuple<Args...> args)
{
return detail::call (func, args, typename make_indices<sizeof...(Args)>::type {});
return detail::call (func, args, std::make_index_sequence<sizeof...(Args)> {});
}
@ -137,9 +137,9 @@ namespace util::tuple {
template <
typename
> class F,
typename I = typename make_indices<
typename I = std::make_index_sequence<
std::tuple_size<T>::value
>::type
>
>
struct map;
@ -155,7 +155,7 @@ namespace util::tuple {
struct map<
T,
F,
indices<I...>
std::index_sequence<I...>
> {
typedef std::tuple<
typename F<

View File

@ -11,29 +11,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright 2015 Danny Robson <danny@nerdcruft.net>
* Copyright 2017 Danny Robson <danny@nerdcruft.net>
*/
#ifndef __UTIL_VARIADIC_HPP
#define __UTIL_VARIADIC_HPP
#include <cstddef>
namespace util {
template <size_t ...N>
struct indices
{
typedef indices<N..., sizeof...(N)> next;
};
namespace util::variadic {
template <size_t N>
struct make_indices
{
typedef typename make_indices<N-1>::type::next type;
};
}
#include "variadic.ipp"
#endif

View File

@ -1,29 +0,0 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright 2015 Danny Robson <danny@nerdcruft.net>
*/
#ifdef __UTIL_VARIADIC_IPP
#error
#endif
#define __UTIL_VARIADIC_IPP
namespace util {
template<>
struct make_indices<0>
{
typedef indices<> type;
};
}