From 49501047bcab4220c314c59b2ca601ac33c3c0cb Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 27 Oct 2017 12:47:38 -0600 Subject: [PATCH] Simplify variadic constructors. --- include/deal.II/base/patterns.h | 41 +++++++++++++-------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/include/deal.II/base/patterns.h b/include/deal.II/base/patterns.h index 7f143c4303..d694d4e1b4 100644 --- a/include/deal.II/base/patterns.h +++ b/include/deal.II/base/patterns.h @@ -1254,45 +1254,36 @@ namespace Patterns { template Tuple::Tuple(const char *separator, - const PatternTypes &... ps) : - separator(separator) - { - static_assert(is_base_of_all::value, - "Not all of the input arguments of this function " - "are derived from PatternBase"); - std::initializer_list 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 Tuple::Tuple(const std::string &separator, - const PatternTypes &... ps) : - separator(separator) + const PatternTypes &... ps) + : + separator (separator) { static_assert(is_base_of_all::value, "Not all of the input arguments of this function " "are derived from PatternBase"); - std::initializer_list pss = { &ps... }; - for (auto p : pss) - patterns.push_back(p->clone()); + auto pattern_pointers = { (static_cast(&ps))... }; + for (auto p : pattern_pointers) + patterns.push_back (p->clone()); } template - Tuple::Tuple(const PatternTypes &... ps) : - separator(",") - { - static_assert(is_base_of_all::value, - "Not all of the input arguments of this function " - "are derived from PatternBase"); - std::initializer_list 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...) + {} -- 2.39.5