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

renamed requires_ to require to conform to dune naming

parent 218b236d
......@@ -16,13 +16,13 @@ namespace AMDiS
struct HasVectorAccess
{
template <class V, class I>
auto requires_(V&& v, I&& i) -> decltype( v[i] );
auto require(V&& v, I&& i) -> decltype( v[i] );
};
struct HasMatrixAccess
{
template <class M, class I, class J>
auto requires_(M&& m, I&& i, J&& j) -> decltype( m[i][j] );
auto require(M&& m, I&& i, J&& j) -> decltype( m[i][j] );
};
} // end namespace Definition
......
......@@ -64,20 +64,18 @@ namespace AMDiS
struct Callable
{
template <class F, class... Args>
auto requires_(F&& f, Args&&... args) -> decltype(f(FWD(args)...));
auto require(F&& f, Args&&... args) -> decltype(f(FWD(args)...));
};
// idx[0]
struct MultiIndex
{
template <class MI>
auto requires_(MI&& idx) -> decltype(
Concepts::valid_expr(
idx[0],
idx.size(),
idx.max_size()
/* ,idx.resize() */
));
auto require(MI&& idx) -> decltype(
idx[0],
idx.size(),
idx.max_size()
);
};
} // end namespace Definition
......@@ -87,19 +85,30 @@ namespace AMDiS
template <class... Ts>
constexpr bool Same = Traits::IsSame<Ts...>::value;
template <class... Ts>
using Same_t = Traits::IsSame<Ts...>;
/// Types are the same, up to decay of qualifiers
template <class A, class B>
constexpr bool Similar = Traits::IsSimilar<A, B>::value;
/// \brief A Collable is a function `F` that can be called with arguments of type `Args...`.
template <class A, class B>
using Similar_t = Traits::IsSimilar<A, B>;
/// \brief A Callable is a function `F` that can be called with arguments of type `Args...`.
/**
* To be used as follows: `Concepts::Collable<F, Args...>`. Returns true, if
* To be used as follows: `Concepts::Callable<F, Args...>`. Returns true, if
* an instance of `F` can be called by `operator()` with arguments of type
* `Args...`.
**/
template <class F, class... Args>
constexpr bool Callable = models<Definition::Callable(F, Args...)>;
template <class F, class... Args>
using Callable_t = bool_t<Callable<F, Args...>>;
/// \brief A Functor is a function `F` with signature `Signature`.
/**
......@@ -110,13 +119,25 @@ namespace AMDiS
template <class F, class Signature> // F, Signature=Return(Arg)
constexpr bool Functor = Dune::Functions::Concept::isFunction<F, Signature>();
template <class F, class Signature> // F, Signature=Return(Arg)
using Functor_t = bool_t<Functor<F, Signature>>;
/// A predicate is a function that returns a boolean.
template <class F, class... Args>
constexpr bool Predicate = Functor<F, bool(Args...)>;
template <class F, class... Args>
using Predicate_t = Functor_t<F, bool(Args...)>;
/// A multi-index type
template <class MI>
constexpr bool MultiIndex = models<Definition::MultiIndex(MI)>;
template <class MI>
using MultiIndex_t = bool_t<MultiIndex<MI>>;
/** @} **/
} // end namespace Concepts
......
......@@ -27,21 +27,10 @@ namespace AMDiS
{};
template <class Concept, class... Ts>
struct models<Concept(Ts...), void_t< decltype(std::declval<Concept>().requires_(std::declval<Ts>()...)) >>
struct models<Concept(Ts...), void_t< decltype(std::declval<Concept>().require(std::declval<Ts>()...)) >>
: std::true_type
{};
struct valid_expr
{
template <class... Ts>
void operator()(Ts&&...) const;
#if defined(__GNUC__) && !defined(__clang__)
template <class... Ts>
void operator()(Ts const&...) const;
#endif
};
} // end namespace Impl_
......@@ -49,7 +38,8 @@ namespace AMDiS
template <class Concept>
constexpr bool models = Impl_::models<Concept>::value;
constexpr Impl_::valid_expr valid_expr = {};
template <class Concept>
using models_t = Impl_::models<Concept>;
#endif // DOXYGEN
} // end namespace Concepts
......
......@@ -25,43 +25,43 @@ namespace AMDiS
struct HasLocalFunction
{
template <class F>
auto requires_(F&& f) -> decltype( localFunction(f) );
auto require(F&& f) -> decltype( localFunction(f) );
};
struct HasDerivative
{
template <class F>
auto requires_(F&& f) -> decltype( derivative(f) );
auto require(F&& f) -> decltype( derivative(f) );
};
struct HasLocalFunctionDerivative
{
template <class F>
auto requires_(F&& f) -> decltype( derivative(localFunction(f)) );
auto require(F&& f) -> decltype( derivative(localFunction(f)) );
};
struct HasLocalFunctionOrder
{
template <class F>
auto requires_(F&& f) -> decltype( order(localFunction(f)) );
auto require(F&& f) -> decltype( order(localFunction(f)) );
};
struct HasPartial
{
template <class F>
auto requires_(F&& f) -> decltype( partial(f, index_<0>) );
auto require(F&& f) -> decltype( partial(f, index_<0>) );
};
struct HasOrder
{
template <class F>
auto requires_(F&& f) -> decltype( order(f) );
auto require(F&& f) -> decltype( order(f) );
};
struct HasGridFunctionTypes
{
template <class GF>
auto requires_(GF const& /*gf*/) -> void_t<
auto require(GF const& /*gf*/) -> void_t<
typename GF::Range,
typename GF::Domain,
typename GF::EntitySet >;
......@@ -78,26 +78,44 @@ namespace AMDiS
template <class GF>
constexpr bool HasLocalFunction = models<Definition::HasLocalFunction(GF)>;
template <class GF>
using HasLocalFunction_t = models_t<Definition::HasLocalFunction(GF)>;
/// \brief GridFunction GF has free function `derivative(F)`
template <class GF>
constexpr bool HasDerivative = models<Definition::HasDerivative(GF)>;
template <class GF>
using HasDerivative_t = models_t<Definition::HasDerivative(GF)>;
/// \brief GridFunction GF has free function `derivative(localFunction(F))`
template <class GF>
constexpr bool HasLocalFunctionDerivative = models<Definition::HasLocalFunctionDerivative(GF)>;
template <class GF>
using HasLocalFunctionDerivative_t = models_t<Definition::HasLocalFunctionDerivative(GF)>;
/// \brief GridFunction GF has free function `order(localFunction(F))`
template <class GF>
constexpr bool HasLocalFunctionOrder = models<Definition::HasLocalFunctionOrder(GF)>;
template <class GF>
using HasLocalFunctionOrder_t = models_t<Definition::HasLocalFunctionOrder(GF)>;
/// \brief Functor F has free function `partial(F,_0)`
template <class F>
constexpr bool HasPartial = models<Definition::HasPartial(F)>;
template <class F>
using HasPartial_t = models_t<Definition::HasPartial(F)>;
/// \brief LocalFuncion LF has free function `order(F)`
template <class LF>
constexpr bool HasOrder = models<Definition::HasOrder(LF)>;
template <class LF>
using HasOrder_t = models_t<Definition::HasOrder(LF)>;
/// \brief Functor F is collable with GlobalCoordinates `F(Dune::FieldVector<double,DOW>)`
#ifndef WORLDDIM
......@@ -110,12 +128,18 @@ namespace AMDiS
Definition::CallableDow<F, WORLDDIM>;
#endif
template <class F>
using CallableDomain_t = bool_t<CallableDomain<F>>;
/// \brief GridFunction GF is a Type that has LocalFunction and provides some
/// typedefs for `Domain`, `Range`, and `EntitySet`.
template <class GF>
constexpr bool GridFunction =
HasLocalFunction<GF> && models<Definition::HasGridFunctionTypes(GF)>;
template <class GF>
using GridFunction_t = bool_t<GridFunction<GF>>;
/// \brief Concept is fulfilled, if at least one of the massed Expressions
/// can be converted to a GridFunction, or is already a GridFunction.
template <class... GFs>
......@@ -123,6 +147,9 @@ namespace AMDiS
any_of_v<GridFunction<remove_cvref_t<GFs>>...> ||
any_of_v<Traits::IsPreGridFunction<remove_cvref_t<GFs>>::value...>;
template <class... GFs>
using AnyGridFunction_t = bool_t<AnyGridFunction<GFs...>>;
/** @} **/
} // end namespace Concepts
......
......@@ -15,12 +15,15 @@ namespace AMDiS
struct HasFunctorOrder
{
template <class F, int... I>
auto requires_(F&& f, std::integer_sequence<int,I...>) -> decltype( order(f, I...) );
auto require(F&& f, std::integer_sequence<int,I...>) -> decltype( order(f, I...) );
};
}
template <class F, int N>
constexpr bool HasFunctorOrder = models<Definition::HasFunctorOrder(F, std::make_integer_sequence<int,N>)>;
template <class F, int N>
using HasFunctorOrder_t = models_t<Definition::HasFunctorOrder(F, std::make_integer_sequence<int,N>)>;
}
namespace Operation
......
Supports Markdown
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