[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaTemplate / instantiate-expanded-type-constraint.cpp
blob73fef87b97822d6893b5d7dab738e21332e92919
1 // RUN: %clang_cc1 -std=c++2a -verify %s
3 template<typename T, typename U>
4 constexpr bool is_same_v = false;
6 template<typename T>
7 constexpr bool is_same_v<T, T> = true;
9 template<typename T, typename U>
10 concept same_as = is_same_v<T, U>;
11 // expected-note@-1{{because 'is_same_v<int, _Bool>' evaluated to false}}
13 template<typename T, typename... Us>
14 concept either = (is_same_v<T, Us> || ...);
16 template<typename... Ts>
17 struct T {
18 template<same_as<Ts>... Us>
19 // expected-note@-1{{because 'same_as<int, _Bool>' evaluated to false}}
20 static void foo(Us... u, int x) { };
21 // expected-note@-1{{candidate template ignored: deduced too few arguments}}
22 // expected-note@-2{{candidate template ignored: constraints not satisfied}}
24 template<typename... Us>
25 struct S {
26 template<either<Ts, Us...>... Vs>
27 static void foo(Vs... v);
31 int main() {
32 T<int, bool>::foo(1); // expected-error{{no matching function for call to 'foo'}}
33 T<int, bool>::foo(1, 2, 3); // expected-error{{no matching function for call to 'foo'}}
34 T<int, bool>::S<char>::foo(1, 'a');
35 T<int, bool>::S<char>::foo('a', true);