From 9249e3f07b6fdb361c865d40b6f55b1283eed3fd Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 4 Oct 2018 22:42:23 -0600 Subject: [PATCH] Add a variadic constructor to hp::QCollection. --- include/deal.II/hp/q_collection.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/deal.II/hp/q_collection.h b/include/deal.II/hp/q_collection.h index 8f37004529..7d0b05ebbd 100644 --- a/include/deal.II/hp/q_collection.h +++ b/include/deal.II/hp/q_collection.h @@ -62,6 +62,15 @@ namespace hp */ explicit QCollection(const Quadrature &quadrature); + /** + * Constructor. This constructor creates a QCollection from one or + * more quadrature objects passed to the constructor. For this + * call to be valid, all arguments need to be of types derived + * from class Quadrature. + */ + template + explicit QCollection(const QTypes &... quadrature_objects); + /** * Adds a new quadrature rule to the QCollection. In most cases, you will * want to add quadrature rules in the same order as the elements were @@ -136,6 +145,24 @@ namespace hp /* --------------- inline functions ------------------- */ + template + template + QCollection::QCollection(const QTypes &... quadrature_objects) + { + static_assert(is_base_of_all, QTypes...>::value, + "Not all of the input arguments of this function " + "are derived from Quadrature!"); + + // loop over all of the given arguments and add the quadrature objects to + // this collection. Inlining the definition of q_pointers causes internal + // compiler errors on GCC 7.1.1 so we define it separately: + const auto q_pointers = {&quadrature_objects...}; + for (auto p : q_pointers) + push_back(*p); + } + + + template inline unsigned int QCollection::size() const -- 2.39.5