c++, coroutines: Simplify separation of the user function body and ramp.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1y / lambda-generic-xcfun.C
blobd8f5ec15aed13159f5291e0807256d5b7e700d85
1 // Explicit generic lambda conversion to function ptr test from N3690 5.1.2.6
2 // { dg-do compile { target c++14 } }
3 // { dg-options "" }
5 void f1(int (*)(int)) { }
6 void f2(char (*)(int)) { }
7 void g(int (*)(int)) { } // #1
8 void g(char (*)(char)) { } // #2
9 void h(int (*)(int)) { } // #3
10 void h(char (*)(int)) { } // #4
12 int main()
14   auto glambda = [] <typename T> (T a) { return a; };
15   int (*fp)(int) = glambda;
16   f1(glambda); // OK
17   f2(glambda); // { dg-error "invalid user-defined conversion" }
18   g(glambda); // { dg-error "ambiguous" }
19   h(glambda); // OK: calls #3 since it is convertible from ID
20   int& (*fpi)(int*) = [] <typename T> (T* a) -> auto& { return *a; }; // OK
22   auto GL = [] <typename T> (T a) { return a; };
23   int (*GL_int)(int) = GL; // OK: through conversion function template
24   GL_int(3);