xref: /llvm-project/clang/test/SemaCXX/lambdas-implicit-explicit-template.cpp (revision 0bff3a965022647fcdd17cc8f2217f5a2cd30b4c)
1 // RUN: %clang_cc1 -std=c++20 -DEXPLICIT -verify %s
2 // RUN: %clang_cc1 -std=c++17 -DEXPLICIT -verify -Wno-c++20-extensions %s
3 // RUN: %clang_cc1 -std=c++14 -verify %s
4 
5 // expected-no-diagnostics
6 
7 #ifdef EXPLICIT
8 
9 template <typename F>
a(F && f)10 void a(F &&f) {
11   f.template operator()<0>();
12 }
13 
14 template <typename F>
b(F && f)15 void b(F &&f) {
16   a([=]<int i>() {
17     f.template operator()<i>();
18   });
19 }
20 
c()21 void c() {
22   b([&]<int i>() {
23   });
24 }
25 
26 #endif
27 
a1(F f)28 template <typename F> void a1(F f) { f.operator()(0); }
29 
b1(F f)30 template <typename F> void b1(F f) {
31   a1([=](auto i) { f.operator()(i); });
32 }
33 
c1()34 void c1() {
35   b1([&](auto i) {});
36 }
37 
c2()38 void c2() {
39   const auto lambda = [&](auto arg1) {};
40   [&](auto arg2) { lambda.operator()(arg2); }(0);
41 }
42 
__anona72851920502(auto) 43 auto d = [](auto) {};
44 
45 template <typename T>
d1(T x)46 void d1(T x) { d.operator()(x); }
47 
d2()48 void d2() { d1(0); }
49 
__anona72851920602(auto)50 template <typename T> int e1 = [](auto){ return T(); }.operator()(T());
51 int e2 = e1<int>;
52