variadic: add index helper type

This commit is contained in:
Danny Robson 2015-04-20 17:13:14 +10:00
parent 1be5be38ea
commit f9e8ea78bf
4 changed files with 90 additions and 0 deletions

View File

@ -186,6 +186,9 @@ UTIL_FILES = \
types/traits.hpp \ types/traits.hpp \
uri.hpp \ uri.hpp \
uri.cpp \ uri.cpp \
variadic.cpp \
variadic.hpp \
variadic.ipp \
vector.cpp \ vector.cpp \
vector.hpp \ vector.hpp \
version.cpp \ version.cpp \

19
variadic.cpp Normal file
View File

@ -0,0 +1,19 @@
/*
* 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>
*/
#include "variadic.hpp"
// Make sure _someone_ includes the header for syntax checking

39
variadic.hpp Normal file
View File

@ -0,0 +1,39 @@
/*
* 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>
*/
#ifndef __UTIL_VARIADIC_HPP
#define __UTIL_VARIADIC_HPP
#include <cstddef>
namespace util {
template <size_t ...N>
struct indices
{
typedef indices<N..., sizeof...(N)> next;
};
template <size_t N>
struct make_indices
{
typedef typename make_indices<N-1>::type::next type;
};
}
#include "variadic.ipp"
#endif

29
variadic.ipp Normal file
View File

@ -0,0 +1,29 @@
/*
* 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;
};
}