From: Wolfgang Bangerth Date: Mon, 21 Aug 2017 23:05:11 +0000 (-0600) Subject: Simplify code that uses variadic templates. X-Git-Tag: v9.0.0-rc1~1193^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3edbdb6ce567fd811dd27b8c566ee321ebaef95a;p=dealii.git Simplify code that uses variadic templates. It turns out that we can do '&args...' to get the addresses of the objects, and then '{ &args... }' to get a std::initializer_list that we can iterate over. This makes the code significantly easier to read. --- diff --git a/include/deal.II/hp/fe_collection.h b/include/deal.II/hp/fe_collection.h index 6ed435e74d..060c8da695 100644 --- a/include/deal.II/hp/fe_collection.h +++ b/include/deal.II/hp/fe_collection.h @@ -457,16 +457,13 @@ namespace hp static_assert(is_base_of_all, FETypes...>::value, "Not all of the input parameters are derived from FiniteElement!"); - // We want to call 'push_back' for each of the arguments. To do so parameter - // pack expansion comes in handy. Unfortunately, we can't just write - // push_back(fes)...; - // but have to treat this as arguments to some function which doesn't need - // to do anything with it. Now, - // [](...) {}(push_back(fes)...); - // doesn't work as well because the ellipsis cannot deal with no parameters - // at all. Hence, we extend the return value of each of the return values - // by zero using the comma operator. - [](...) {}((push_back(fes),0)...); + // loop over all of the given arguments and add the finite + // elements to this collection + for (auto p : + { + &fes... + }) + push_back (*p); }