From: Wolfgang Bangerth Date: Thu, 14 Sep 2017 20:41:08 +0000 (-0600) Subject: Allow not specifying the multiplicity in the FESystem constructor. X-Git-Tag: v9.0.0-rc1~1054^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc2d367d062ea093e036172e003ad90d4cb030ee;p=dealii.git Allow not specifying the multiplicity in the FESystem constructor. --- diff --git a/include/deal.II/fe/fe_system.h b/include/deal.II/fe/fe_system.h index caa7920589..f9218330df 100644 --- a/include/deal.II/fe/fe_system.h +++ b/include/deal.II/fe/fe_system.h @@ -448,12 +448,30 @@ public: * elements. The temporary is destroyed again at the end of the code that * corresponds to this line, but this does not matter because FESystem * creates its own copy of the FE_Q object. + * + * As a shortcut, this constructor also allows calling + * @code + * FESystem fe (FE_Q(2)^dim, FE_Q(1)); + * @endcode + * instead of the more explicit + * @code + * FESystem fe (FE_Q(2)^dim, FE_Q(1)^1); + * @endcode + * In other words, if no multiplicity for an element is explicitly specified + * via the exponentiation operation, then it is assumed to be one (as one + * would have expected). */ template ::type..., - std::pair>, - unsigned int>>::value>::type> - FESystem (FEPairs&& ... fe_pairs); + typename = typename enable_if_all< + (std::is_same::type, + std::pair>, unsigned int>>::value + || + std::is_base_of, + typename std::decay::type>::value) + ... + >::type + > + FESystem (FEPairs &&... fe_pairs); /** * Same as above allowing the following syntax: @@ -1149,6 +1167,26 @@ namespace return fe_system.second > 0; }); } + + + + template + std::pair >, unsigned int> + promote_to_fe_pair (const FiniteElement &fe) + { + return std::make_pair >, + unsigned int> (std::move(fe.clone()), 1u); + } + + + + template + auto + promote_to_fe_pair (std::pair >, unsigned int> &&p) + -> decltype(std::forward >, unsigned int> >(p)) + { + return std::forward >, unsigned int> >(p); + } } @@ -1157,10 +1195,11 @@ namespace // If we decide to remove the deprecated constructors, we might just use the variadic // constructor with a suitable static_assert instead of the std::enable_if. template -template +template FESystem::FESystem (FEPairs &&... fe_pairs) : - FESystem ({std::forward(fe_pairs)...}) + FESystem ({promote_to_fe_pair(std::forward(fe_pairs))...}) {}