PR c++/56973, DR 696 - capture constant variables only as needed.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1y / lambda-generic-const4.C
blobd56f379c680b39b78c14eaba41f7f2b2ef623d4d
1 // PR c++/81525
2 // { dg-do compile { target c++14 } }
4 template <int i> struct A {
5   constexpr operator int () const { return i; }
6 };
7 template <int i> constexpr A<i> a = {};
9 template <typename F> void foo (F f) {
10   f (A<0>{});
12 template <typename T>
13 void bar (T) {
14   constexpr auto N = a<1>;
15   auto f = [&] (auto i) {
16     return static_cast<int>(N) == 1;
17   };
18   foo (f);
20 int main () { bar (0); }