7#ifndef DUNE_FUNCTIONS_COMMON_SIGNATURE_HH
8#define DUNE_FUNCTIONS_COMMON_SIGNATURE_HH
13#include <dune/functions/common/defaultderivativetraits.hh>
30 struct yes { std::size_t dummy[2]; };
31 struct no { std::size_t dummy[1]; };
34 static yes test(
const decltype(&C::operator()) *);
38 enum { value = (
sizeof(test<F>(0)) ==
sizeof(yes)) };
41template<
typename R,
typename D>
42struct IsCallable<R(D)>
44 enum { value =
true };
47template<
typename R,
typename D>
48struct IsCallable<R(*)(D)>
50 enum { value =
true };
59template<class Signature, bool isCallable = IsCallable<Signature>::value >
70template <
typename C,
typename R,
typename D>
71struct SignatureTraits<R(C::*)(D) const, true>
72 :
public SignatureTraits<R(D), true>
76template <
typename C,
typename R,
typename D>
77struct SignatureTraits<R(C::*)(D), true>
78 :
public SignatureTraits<R(D), true>
82template <
typename R,
typename D>
83struct SignatureTraits<R(*)(D),
true>
84 :
public SignatureTraits<R(D),
true>
88template<
class R,
class D>
89struct SignatureTraits<R(D), true>
94 using RawRange = std::decay_t<Range>;
95 using RawDomain = std::decay_t<Domain>;
97 using RawSignature = RawRange(RawDomain);
99 template<
template<
class>
class DerivativeTraits=DefaultDerivativeTraits>
100 using DerivativeSignature =
typename DerivativeTraits<RawSignature>::Range(Domain);
105template<
class Signature,
template<
class>
class DerivativeTraits=DefaultDerivativeTraits>
117template<
class Range,
class Domain,
template<
class>
class DerivativeTraitsT>
118struct SignatureTag<Range(Domain), DerivativeTraitsT>
120 using Signature = Range(Domain);
123 using DerivativeTraits = DerivativeTraitsT<T>;
136template<
class Range,
class Domain,
template<
class>
class DerivativeTraits>
139 using DerivativeRange =
typename DerivativeTraits<Range(Domain)>::Range;
140 return SignatureTag<DerivativeRange(Domain), DerivativeTraits>();
158template<std::
size_t maxOrder,
class Signature,
template<
class>
class DerivativeTraits>
161 if constexpr (maxOrder==0) {
163 return std::make_tuple(tag);
170 return std::apply([&](
auto&&... tailTags){
171 return std::make_tuple(tag, tailTags...);
auto derivativeSignatureTag(SignatureTag< Range(Domain), DerivativeTraits > tag)
Construct SignatureTag for derivative.
Definition: signature.hh:137
auto derivativeSignatureTags(Dune::Functions::SignatureTag< Signature, DerivativeTraits > tag)
Construct SignatureTags for derivatives.
Definition: signature.hh:159
Definition: polynomial.hh:17
Helper class to check that F is callable.
Definition: signature.hh:24
Helper class to deduce the signature of a callable.
Definition: signature.hh:60