]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Simplify variadic constructors. 5342/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 27 Oct 2017 18:47:38 +0000 (12:47 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 27 Oct 2017 18:47:38 +0000 (12:47 -0600)
include/deal.II/base/patterns.h

index 7f143c43036515e71dd45988018a12491457b260..d694d4e1b419faced6fd24c5ccc4c5b8afdac334 100644 (file)
@@ -1254,45 +1254,36 @@ namespace Patterns
 {
   template<class... PatternTypes>
   Tuple::Tuple(const char *separator,
-               const PatternTypes &... ps) :
-    separator(separator)
-  {
-    static_assert(is_base_of_all<PatternBase, PatternTypes...>::value,
-                  "Not all of the input arguments of this function "
-                  "are derived from PatternBase");
-    std::initializer_list<const PatternBase *> pss = { &ps... };
-    for (auto p : pss)
-      patterns.push_back(p->clone());
-  }
+               const PatternTypes &... ps)
+    :
+    // simply forward to the std::string version
+    Tuple (std::string(separator), ps...)
+  {}
 
 
 
   template<class... PatternTypes>
   Tuple::Tuple(const std::string &separator,
-               const PatternTypes &... ps) :
-    separator(separator)
+               const PatternTypes &... ps)
+    :
+    separator (separator)
   {
     static_assert(is_base_of_all<PatternBase, PatternTypes...>::value,
                   "Not all of the input arguments of this function "
                   "are derived from PatternBase");
-    std::initializer_list<const PatternBase *> pss = { &ps... };
-    for (auto p : pss)
-      patterns.push_back(p->clone());
+    auto pattern_pointers = { (static_cast<const PatternBase *>(&ps))... };
+    for (auto p : pattern_pointers)
+      patterns.push_back (p->clone());
   }
 
 
 
   template<class... PatternTypes>
-  Tuple::Tuple(const PatternTypes &... ps) :
-    separator(",")
-  {
-    static_assert(is_base_of_all<PatternBase, PatternTypes...>::value,
-                  "Not all of the input arguments of this function "
-                  "are derived from PatternBase");
-    std::initializer_list<const PatternBase *> pss = { &ps... };
-    for (auto p : pss)
-      patterns.push_back(p->clone());
-  }
+  Tuple::Tuple(const PatternTypes &... ps)
+    :
+    // forward to the version with the separator argument
+    Tuple (std::string(","), ps...)
+  {}
 
 
 

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.