Yeah, no fair
The subtraction of the analytical solution from the numerical solution produced an expression template rather than an actual vector.
1 Like
Lambdas do produce functors. They just do it by closures. The body of the lambda just defines the body of operator()
. Any variable that isn’t explicitly declared in scope is captured either by value or by reference. In practice, those just get set as member variables on the functor.
So if I do something like
double a;
auto f = [](const auto& x) { return a + x; }
what happens is that you get the same behavior as if you’d done this:
struct anonymous12379 {
double a_;
anonymous(double a) : a_(a) { }
template <typename T>
auto operator()(const T& x) -> decltype(a_ + x) { return a_ + x; }
};
double a;
auto f = anonymous12379(a);