Dune Core Modules (2.8.0)

function.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_FUNCTION_HH_SILENCE_DEPRECATION
4#warning This file is deprecated after Dune 2.7! Use C++ function objects and std::function stuff instead!
5#else // !DUNE_FUNCTION_HH_SILENCE_DEPRECATION
6#undef DUNE_FUNCTION_HH_SILENCE_DEPRECATION
7#endif // !DUNE_FUNCTION_HH_SILENCE_DEPRECATION
8
9#ifndef DUNE_FUNCTION_HH
10#define DUNE_FUNCTION_HH
11
12#include <utility>
13
15#include "typetraits.hh"
16
17namespace Dune {
18
34 template <class Domain, class Range>
35 class
36 [[deprecated("Dune::Function is deprecated after Dune 2.7. Use C++ "
37 "function objects instead!")]]
39 {
40 typedef typename std::remove_cv<typename std::remove_reference< Domain >::type >::type RawDomainType;
41 typedef typename std::remove_cv<typename std::remove_reference< Range >::type >::type RawRangeType;
42
43 public:
44
46 typedef RawRangeType RangeType;
47
49 typedef RawDomainType DomainType;
50
52 struct Traits
53 {
54 typedef RawDomainType DomainType;
55 typedef RawRangeType RangeType;
56 };
57
64 void evaluate(const typename Traits::DomainType& x, typename Traits::RangeType& y) const;
65 }; // end of Function class
66
67
68
80 template <class DomainType, class RangeType>
81 class
82 [[deprecated("Dune::VirtualFunction is deprecated after Dune 2.7. Use C++ "
83 "function objects and std::function instead!")]]
85 {
86 public:
88
89 virtual ~VirtualFunction() {}
96 virtual void evaluate(const typename Traits::DomainType& x, typename Traits::RangeType& y) const = 0;
97 }; // end of VirtualFunction class
99
100 namespace Impl {
101
103 template<typename Domain, typename Range, typename F>
104 class LambdaVirtualFunction final
105 : public VirtualFunction<Domain, Range>
106 {
107 public:
108 LambdaVirtualFunction(F&& f)
109 : f_(std::move(f))
110 {}
111
112 LambdaVirtualFunction(const F& f)
113 : f_(f)
114 {}
115
116 void evaluate(const Domain& x, Range& y) const override
117 {
118 y = f_(x);
119 }
120
121 private:
122 const F f_;
123 };
125
126 } /* namespace Impl */
127
147 template<typename Domain, typename Range, typename F>
148 [[deprecated("Dune::LambdaVirtualFunction is deprecated after Dune 2.7. "
149 "Use std::function instead!")]]
150 Impl::LambdaVirtualFunction< Domain, Range, std::decay_t<F> >
152 {
153 return {std::forward<F>(f)};
154 }
155
158} // end namespace
159
160#endif
Base class template for function classes.
Definition: function.hh:39
RawDomainType DomainType
Raw type of output variable with removed reference and constness.
Definition: function.hh:49
void evaluate(const typename Traits::DomainType &x, typename Traits::RangeType &y) const
Function evaluation.
RawRangeType RangeType
Raw type of input variable with removed reference and constness.
Definition: function.hh:46
Virtual base class template for function classes.
Definition: function.hh:85
virtual void evaluate(const typename Traits::DomainType &x, typename Traits::RangeType &y) const =0
Function evaluation.
Definition of the DUNE_DEPRECATED macro for the case that config.h is not available.
Impl::LambdaVirtualFunction< Domain, Range, std::decay_t< F > > makeVirtualFunction(F &&f)
make VirtualFunction out of a function object
Definition: function.hh:151
#define DUNE_NO_DEPRECATED_END
Ignore deprecation warnings (end)
Definition: deprecated.hh:61
#define DUNE_NO_DEPRECATED_BEGIN
Ignore deprecation warnings (start)
Definition: deprecated.hh:55
Dune namespace.
Definition: alignedallocator.hh:11
Traits class containing raw types.
Definition: function.hh:53
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 22, 23:30, 2024)