]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a variadic constructor to hp::QCollection.
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 5 Oct 2018 04:42:23 +0000 (22:42 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 5 Oct 2018 04:42:23 +0000 (22:42 -0600)
include/deal.II/hp/q_collection.h

index 8f370045295867c18c9062b67b10dc2d5a27963f..7d0b05ebbddb7cbb3559036a1706cad64a303e74 100644 (file)
@@ -62,6 +62,15 @@ namespace hp
      */
     explicit QCollection(const Quadrature<dim> &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<dim>.
+     */
+    template <class... QTypes>
+    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 <int dim>
+  template <class... QTypes>
+  QCollection<dim>::QCollection(const QTypes &... quadrature_objects)
+  {
+    static_assert(is_base_of_all<Quadrature<dim>, QTypes...>::value,
+                  "Not all of the input arguments of this function "
+                  "are derived from Quadrature<dim>!");
+
+    // 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 <int dim>
   inline unsigned int
   QCollection<dim>::size() const

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.