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