blob: 98b27c1d06b12065f35a9ae57c7b82526661e5a5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
|
// Testcase from P0170R1
// { dg-do compile { target c++17 } }
// 'v' & 'm' are odr-used but do not occur in a constant-expression within the nested
// lambda, so are well-formed.
auto monad = [](auto v) { return [=] { return v; }; };
auto bind = [](auto m) {
return [=](auto fvm) { return fvm(m()); };
};
// OK to have captures to automatic objects created during constant expression evaluation.
static_assert(bind(monad(2))(monad)() == monad(2)());
|