From df19e77f59bfb4b0c53362bb8a806332528ffdbe Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Fri, 13 Jul 2018 01:08:23 +0200 Subject: [PATCH] [BL] Move IntegerSequence into Functional. --- BaseLib/Functional.h | 30 +++++++++++++++++++++++++++++- BaseLib/TMPUtil.h | 43 ------------------------------------------- 2 files changed, 29 insertions(+), 44 deletions(-) delete mode 100644 BaseLib/TMPUtil.h diff --git a/BaseLib/Functional.h b/BaseLib/Functional.h index 7f052cb580a..8f2e521d955 100644 --- a/BaseLib/Functional.h +++ b/BaseLib/Functional.h @@ -11,7 +11,6 @@ #include <functional> #include "baselib_export.h" -#include "BaseLib/TMPUtil.h" namespace BaseLib { @@ -139,6 +138,35 @@ struct FunctionTraits<ReturnType (Object::*)(Args...) const> { } // namespace detail +//! Has sequence of integers as template parameters +template <int...> +struct IntegerSequence { +}; + +//! Generates an IntegerSequence. +//! +//! \see http://stackoverflow.com/a/7858971 +template <int N, int... S> +struct GenerateIntegerSequence { + // effectively pushes N-1 from the left to the list int... S of integers. + using type = typename GenerateIntegerSequence<N - 1, N - 1, S...>::type; +}; + +template <int... S> +struct GenerateIntegerSequence<0, S...> { + using type = IntegerSequence<S...>; +}; + +/* The template metaprogram proceeds in the following way: + * + * GenerateIntegerSequence<sizeof...(Args)>::type + * + * Assume sizeof...(Args) == 3. Let GIS := GenerateIntegerSequence + * GIS<3, []> + * -> GIS<2, [2]> + * -> GIS<1, [1, 2]> + * -> GIS<0, [0, 1, 2], which has member typedef IntegerSequence<0, 1, 2> + */ /*! Convenience wrapper for std::bind(). * * This function binds the member function pointer \c member of class \c Object diff --git a/BaseLib/TMPUtil.h b/BaseLib/TMPUtil.h deleted file mode 100644 index a3c68aec0bd..00000000000 --- a/BaseLib/TMPUtil.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * \copyright - * Copyright (c) 2012-2018, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - */ - -#pragma once - -namespace BaseLib -{ -//! Has sequence of integers as template parameters -template <int...> -struct IntegerSequence { -}; - -//! Generates an IntegerSequence. -//! -//! \see http://stackoverflow.com/a/7858971 -template <int N, int... S> -struct GenerateIntegerSequence { - // effectively pushes N-1 from the left to the list int... S of integers. - using type = typename GenerateIntegerSequence<N - 1, N - 1, S...>::type; -}; - -template <int... S> -struct GenerateIntegerSequence<0, S...> { - using type = IntegerSequence<S...>; -}; -/* The template metaprogram proceeds in the following way: - * - * GenerateIntegerSequence<sizeof...(Args)>::type - * - * Assume sizeof...(Args) == 3. Let GIS := GenerateIntegerSequence - * GIS<3, []> - * -> GIS<2, [2]> - * -> GIS<1, [1, 2]> - * -> GIS<0, [0, 1, 2], which has member typedef IntegerSequence<0, 1, 2> - */ - -} // namespace BaseLib -- GitLab