[clang][lex] NFCI: Use DirectoryEntryRef in ModuleMap::inferFrameworkModule()
[llvm-project.git] / clang / test / SemaTemplate / lambda-capture-pack.cpp
blob35b2ffcefea35519e3585863bebb6a0a9e09d86e
1 // RUN: %clang_cc1 -std=c++2a -verify %s
3 template<typename ...T, typename ...Lambda> void check_sizes(Lambda ...L) {
4 static_assert(((sizeof(T) == sizeof(Lambda)) && ...));
7 template<typename ...T> void f(T ...v) {
8 // Pack expansion of lambdas: each lambda captures only one pack element.
9 check_sizes<T...>([=] { (void)&v; } ...);
11 // Pack expansion inside lambda: captures all pack elements.
12 auto l = [=] { ((void)&v, ...); };
13 static_assert(sizeof(l) >= (sizeof(T) + ...));
16 template void f(int, char, double);
18 namespace PR41576 {
19 template <class... Xs> constexpr int f(Xs ...xs) {
20 return [&](auto ...ys) { // expected-note {{instantiation}}
21 return ((xs + ys), ...); // expected-warning {{left operand of comma operator has no effect}}
22 }(1, 2);
24 static_assert(f(3, 4) == 6); // expected-note {{instantiation}}