1 // Explicit generic lambda conversion to function ptr test from N3690 5.1.2.6
2 // { dg-do compile { target c++14 } }
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
14 auto glambda = [] <typename T> (T a) { return a; };
15 int (*fp)(int) = glambda;
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