]> https://gitweb.dealii.org/ - dealii.git/commitdiff
std_cxx14::index_sequence and related stuff.
authorLuca Heltai <luca.heltai@sissa.it>
Fri, 27 Oct 2017 11:58:27 +0000 (13:58 +0200)
committerLuca Heltai <luca.heltai@sissa.it>
Sat, 28 Oct 2017 17:57:07 +0000 (19:57 +0200)
include/deal.II/base/patterns.h
include/deal.II/base/std_cxx14/utility.h [new file with mode: 0644]

index cbadcfdb182519c9f1d2c9fbb05401c4fe27b86b..2066fc155c4729c06532dc57bf60eda1bed3e83c 100644 (file)
 #include <deal.II/base/exceptions.h>
 #include <deal.II/base/subscriptor.h>
 #include <deal.II/base/point.h>
-#include <deal.II/base/std_cxx14/memory.h>
 #include <deal.II/base/subscriptor.h>
 #include <deal.II/base/utilities.h>
-#include <deal.II/base/std_cxx14/algorithm.h>
 #include <deal.II/base/template_constraints.h>
 
+#include <deal.II/base/std_cxx14/memory.h>
+#include <deal.II/base/std_cxx14/algorithm.h>
+#include <deal.II/base/std_cxx14/utility.h>
+
 #include <boost/archive/basic_archive.hpp>
 #include <boost/core/demangle.hpp>
 #include <boost/property_tree/ptree_fwd.hpp>
diff --git a/include/deal.II/base/std_cxx14/utility.h b/include/deal.II/base/std_cxx14/utility.h
new file mode 100644 (file)
index 0000000..6c696ec
--- /dev/null
@@ -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 <deal.II/base/config.h>
+
+#include <utility>
+
+#ifndef DEAL_II_WITH_CXX14
+// needed for array type check
+#  include <type_traits>
+#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 <size_t... Ints>
+  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 <class Sequence1, class Sequence2>
+    struct merge_and_renumber;
+
+    template <size_t... I1, size_t... I2>
+    struct merge_and_renumber<index_sequence<I1...>, index_sequence<I2...>>
+      : index_sequence<I1..., (sizeof...(I1)+I2)...>
+        { };
+  }
+  // --------------------------------------------------------------
+
+  template <size_t N>
+  struct make_index_sequence
+    : internal::merge_and_renumber<typename make_index_sequence<N/2>::type,
+      typename make_index_sequence<N - N/2>::type>
+  {};
+
+  template<> struct make_index_sequence<0> : index_sequence<> { };
+  template<> struct make_index_sequence<1> : index_sequence<0> { };
+
+  template<class... T>
+  using index_sequence_for = make_index_sequence<sizeof...(T)>;
+#endif
+}
+DEAL_II_NAMESPACE_CLOSE
+
+#endif // dealii_cxx14_memory_h

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.