FunctionFromCallable.hpp 1.04 KB
Newer Older
1
2
#pragma once

3
4
5
#include <dune/common/version.hh>

#if DUNE_VERSION_LT(DUNE_LOCALFUNCTIONS,2,8)
6
7
#include <dune/common/typeutilities.hh>
#include <dune/functions/common/functionfromcallable.hh>
8
#endif
9
10
11

namespace AMDiS
{
12
#if DUNE_VERSION_LT(DUNE_LOCALFUNCTIONS,2,8)
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  namespace Impl
  {
    template <class Traits, class F,
      class Range = typename Traits::RangeType,
      class Domain = typename Traits::DomainType>
    auto functionFromCallableImpl(F const& f, Dune::PriorityTag<2>)
    {
      return Dune::Functions::FunctionFromCallable<Range(Domain), F>(f);
    }

    template <class Signature, class F>
    auto functionFromCallableImpl(F const& f, Dune::PriorityTag<1>)
    {
      return Dune::Functions::FunctionFromCallable<Signature, F>(f);
    }
  }

  template <class SigTraits, class F>
  auto functionFromCallable(F const& f)
  {
    return Impl::functionFromCallableImpl<SigTraits>(f, Dune::PriorityTag<10>{});
  }
35
36
37
38
#else
  template <class SigTraits, class F>
  F functionFromCallable(F const& f) { return f; }
#endif
39
40

} // end namespace AMDiS