Commit 9b09a70f authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

variadic packs

parent c50bd280
......@@ -54,7 +54,7 @@ namespace AMDiS
// factory to construct a global basis of several lagrange bases, with flat indexing.
template <int deg, int... degs>
struct LagrangePreBasisCreator
: public LagrangePreBasisCreatorImpl<all_of_v<(deg == degs)...>, deg, degs...>
: public LagrangePreBasisCreatorImpl<((deg == degs) &&...), deg, degs...>
{};
......
......@@ -25,39 +25,39 @@ namespace AMDiS
} // end namespace Impl
template <bool... Bs>
using all_of_t = std::is_same<Impl::all_helper<true, Bs...>, Impl::all_helper<Bs..., true>>;
using all_of_t = bool_t<(Bs &&...)>;
template <bool... Bs>
constexpr bool all_of_v = all_of_t<Bs...>::value;
constexpr bool all_of_v = (Bs &&...);
template <bool... Bs>
using and_t = all_of_t<Bs...>;
template <bool... Bs>
using none_of_t = std::is_same<Impl::all_helper<false, Bs...>, Impl::all_helper<Bs..., false>>;
using none_of_t = bool_t<!(Bs ||...)>;
template <bool... Bs>
constexpr bool none_of_v = none_of_t<Bs...>::value;
constexpr bool none_of_v = !(Bs ||...);
template <bool... Bs>
using any_of_t = bool_t<not none_of_t<Bs...>::value>;
using any_of_t = bool_t<(Bs ||...)>;
template <bool... Bs>
constexpr bool any_of_v = any_of_t<Bs...>::value;
constexpr bool any_of_v = (Bs ||...);
template <bool... Bs>
using or_t = any_of_t<Bs...>;
template <bool... Bs>
constexpr bool_t<and_t<Bs...>::value> and_ = {};
constexpr all_of_t<Bs...> and_ = {};
template <bool B0, bool B1>
constexpr bool_t<B0 && B1> operator&&(bool_t<B0>, bool_t<B1>) { return {}; }
template <bool... Bs>
constexpr bool_t<or_t<Bs...>::value> or_ = {};
constexpr any_of_t<Bs...> or_ = {};
template <bool B0, bool B1>
constexpr bool_t<B0 || B1> operator||(bool_t<B0>, bool_t<B1>) { return {}; }
......@@ -67,7 +67,7 @@ namespace AMDiS
using not_t = bool_t<!B>;
template <bool B>
constexpr bool_t<not_t<B>::value> not_ = {};
constexpr bool_t<!B> not_ = {};
template <bool B>
constexpr bool_t<!B> operator!(bool_t<B>) { return {}; }
......
......@@ -156,11 +156,12 @@ namespace AMDiS
**/
template <class Sig, class F, class... LFs,
REQUIRES(Concepts::HasFunctorOrder<F,sizeof...(LFs)>
&& all_of_v<Concepts::HasOrder<LFs>...>)>
&& (Concepts::HasOrder<LFs> &&...))>
int order(FunctorLocalFunction<Sig,F,LFs...> const& lf)
{
return Tools::apply([&lf](auto const&... lgfs) { return order(lf.fct(), order(*lgfs)...); },
lf.localFcts());
return Tools::apply([&lf](auto const&... lgfs) {
return order(lf.fct(), order(*lgfs)...);
}, lf.localFcts());
}
......@@ -239,7 +240,7 @@ namespace AMDiS
template <class Functor, class... GridFcts>
auto makeFunctorGridFunction(Functor const& f, GridFcts const&... gridFcts)
{
static_assert(all_of_v<Concepts::GridFunction<GridFcts>...>,
static_assert((Concepts::GridFunction<GridFcts> &&...),
"All passed parameters must be GridFunctions.");
static_assert(Concepts::Callable<Functor, typename GridFcts::Range...>,
"Range types of grid functions are not compatible with the functor.");
......
......@@ -80,8 +80,8 @@ namespace AMDiS
/// can be converted to a GridFunction, or is already a GridFunction.
template <class... GFs>
constexpr bool AnyGridFunction =
any_of_v<GridFunction<remove_cvref_t<GFs>>...> ||
any_of_v<Traits::IsPreGridFunction<remove_cvref_t<GFs>>::value...>;
(GridFunction<remove_cvref_t<GFs>> ||...) ||
(Traits::IsPreGridFunction<remove_cvref_t<GFs>>::value ||...);
template <class... GFs>
using AnyGridFunction_t = bool_t<AnyGridFunction<GFs...>>;
......
......@@ -72,7 +72,7 @@ namespace AMDiS
// Polynomial order or composed function combines the orders of the sub-functions
template <class F, class... Gs, class... Int,
REQUIRES(Concepts::HasFunctorOrder<F,sizeof...(Gs)>
&& all_of_v<Concepts::HasFunctorOrder<Gs,sizeof...(Int)>...>)>
&& (Concepts::HasFunctorOrder<Gs,sizeof...(Int)> &&...))>
int order(Composer<F,Gs...> const& c, Int... degrees)
{
auto deg = [&](auto const& g) { return order(g, int(degrees)...); };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment