2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1z / constexpr-lambda11.C
blob98b27c1d06b12065f35a9ae57c7b82526661e5a5
1 // Testcase from P0170R1
2 // { dg-do compile { target c++17 } }
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)());