From: Luca Heltai Date: Fri, 27 Oct 2017 11:58:27 +0000 (+0200) Subject: std_cxx14::index_sequence and related stuff. X-Git-Tag: v9.0.0-rc1~848^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cedc6a2d3e8297e84553b283252004b65cd442e3;p=dealii.git std_cxx14::index_sequence and related stuff. --- diff --git a/include/deal.II/base/patterns.h b/include/deal.II/base/patterns.h index cbadcfdb18..2066fc155c 100644 --- a/include/deal.II/base/patterns.h +++ b/include/deal.II/base/patterns.h @@ -21,12 +21,14 @@ #include #include #include -#include #include #include -#include #include +#include +#include +#include + #include #include #include diff --git a/include/deal.II/base/std_cxx14/utility.h b/include/deal.II/base/std_cxx14/utility.h new file mode 100644 index 0000000000..6c696ecafd --- /dev/null +++ b/include/deal.II/base/std_cxx14/utility.h @@ -0,0 +1,71 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- +#ifndef dealii_cxx14_utility_h +#define dealii_cxx14_utility_h + +#include + +#include + +#ifndef DEAL_II_WITH_CXX14 +// needed for array type check +# include +#endif + +DEAL_II_NAMESPACE_OPEN +namespace std_cxx14 +{ +#ifdef DEAL_II_WITH_CXX14 + using std::index_sequence; + using std::make_index_sequence; + using std::index_sequence_for; +#else + template + struct index_sequence + { + using type = index_sequence; + using value_type = size_t; + static constexpr std::size_t size() noexcept { return sizeof...(Ints); } + }; + + // -------------------------------------------------------------- + namespace internal + { + template + struct merge_and_renumber; + + template + struct merge_and_renumber, index_sequence> + : index_sequence + { }; + } + // -------------------------------------------------------------- + + template + struct make_index_sequence + : internal::merge_and_renumber::type, + typename make_index_sequence::type> + {}; + + template<> struct make_index_sequence<0> : index_sequence<> { }; + template<> struct make_index_sequence<1> : index_sequence<0> { }; + + template + using index_sequence_for = make_index_sequence; +#endif +} +DEAL_II_NAMESPACE_CLOSE + +#endif // dealii_cxx14_memory_h