]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Introduce a all_same_as type trait structs
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Mon, 4 Sep 2017 23:25:13 +0000 (01:25 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Tue, 5 Sep 2017 19:51:21 +0000 (21:51 +0200)
include/deal.II/base/template_constraints.h

index 5f2a01149dec598986f2489a80f52ca6c9df6413..fd28c0c3b9ed9c408a1667b3da531917de0e8a59 100644 (file)
@@ -27,7 +27,7 @@ DEAL_II_NAMESPACE_OPEN
 
 namespace
 {
-  // helper struct for is_base_of_all
+  // helper struct for is_base_of_all and all_same_as
   template <bool... Types> struct BoolStorage;
 }
 
@@ -47,6 +47,21 @@ struct is_base_of_all
 
 
 
+/**
+ * This struct is a generalization of std::is_same to template
+ * parameter packs and tests if all of the Types... classes are
+ * in Type classes. The result is stored in the member variable value.
+ */
+template <class Type, class... Types>
+struct all_same_as
+{
+  static constexpr bool value =
+    std::is_same<BoolStorage<std::is_same<Type, Types>::value..., true>,
+    BoolStorage<true, std::is_same<Type, Types>::value...>>::value;
+};
+
+
+
 template <bool, typename> struct constraint_and_return_value;
 
 

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.