3#ifndef DUNE_FUNCTIONS_COMMON_SIGNATURE_HH
4#define DUNE_FUNCTIONS_COMMON_SIGNATURE_HH
9#include <dune/functions/common/defaultderivativetraits.hh>
26 struct yes { std::size_t dummy[2]; };
27 struct no { std::size_t dummy[1]; };
30 static yes test(
const decltype(&C::operator()) *);
34 enum { value = (
sizeof(test<F>(0)) ==
sizeof(yes)) };
37template<
typename R,
typename D>
38struct IsCallable<R(D)>
40 enum { value =
true };
43template<
typename R,
typename D>
44struct IsCallable<R(*)(D)>
46 enum { value =
true };
55template<class Signature, bool isCallable = IsCallable<Signature>::value >
66template <
typename C,
typename R,
typename D>
67struct SignatureTraits<R(C::*)(D) const, true>
68 :
public SignatureTraits<R(D), true>
72template <
typename C,
typename R,
typename D>
73struct SignatureTraits<R(C::*)(D), true>
74 :
public SignatureTraits<R(D), true>
78template <
typename R,
typename D>
79struct SignatureTraits<R(*)(D),
true>
80 :
public SignatureTraits<R(D),
true>
84template<
class R,
class D>
85struct SignatureTraits<R(D), true>
90 using RawRange =
typename std::decay<Range>::type;
91 using RawDomain =
typename std::decay<Domain>::type;
93 using RawSignature = RawRange(RawDomain);
95 template<
template<
class>
class DerivativeTraits=DefaultDerivativeTraits>
96 using DerivativeSignature =
typename DerivativeTraits<RawSignature>::Range(Domain);
101template<
class Signature,
template<
class>
class DerivativeTraits=DefaultDerivativeTraits>
113template<
class Range,
class Domain,
template<
class>
class DerivativeTraitsT>
114struct SignatureTag<Range(Domain), DerivativeTraitsT>
116 using Signature = Range(Domain);
119 using DerivativeTraits = DerivativeTraitsT<T>;
132template<
class Range,
class Domain,
template<
class>
class DerivativeTraits>
135 using DerivativeRange =
typename DerivativeTraits<Range(Domain)>::Range;
136 return SignatureTag<DerivativeRange(Domain), DerivativeTraits>();
154template<std::
size_t maxOrder,
class Signature,
template<
class>
class DerivativeTraits>
157 if constexpr (maxOrder==0) {
159 return std::make_tuple(tag);
166 return std::apply([&](
auto&&... tailTags){
167 return std::make_tuple(tag, tailTags...);
auto derivativeSignatureTag(SignatureTag< Range(Domain), DerivativeTraits > tag)
Construct SignatureTag for derivative.
Definition: signature.hh:133
auto derivativeSignatureTags(Dune::Functions::SignatureTag< Signature, DerivativeTraits > tag)
Construct SignatureTags for derivatives.
Definition: signature.hh:155
Dune namespace.
Definition: alignedallocator.hh:11
Helper class to check that F is callable.
Definition: signature.hh:20
Helper class to deduce the signature of a callable.
Definition: signature.hh:56