[mlir][Vector] Update VectorEmulateNarrowType.cpp (1/N) (#123526)
[llvm-project.git] / clang / test / CXX / temp / temp.constr / temp.constr.order / var-template-partial-specializations.cpp
blob972a4fd0c5c82d0889f14fc2d5d293eb925d322e
1 // RUN: %clang_cc1 -std=c++2a -x c++ -verify %s
3 template<typename T> requires (sizeof(T) >= 4)
4 // expected-note@-1{{similar constraint expressions not considered equivalent}}
5 bool a = false; // expected-note{{template is declared here}}
7 template<typename T> requires (sizeof(T) >= 4 && sizeof(T) <= 10)
8 // expected-note@-1{{similar constraint expression here}}
9 bool a<T> = true; // expected-error{{variable template partial specialization is not more specialized than the primary template}}
11 template<typename T>
12 concept C1 = sizeof(T) >= 4;
14 template<typename T> requires C1<T>
15 bool b = false;
17 template<typename T> requires (C1<T> && sizeof(T) <= 10)
18 bool b<T> = true;
20 template<typename T>
21 concept C2 = sizeof(T) > 1 && sizeof(T) <= 8;
23 template<typename T>
24 bool c = false;
26 template<typename T> requires C1<T>
27 bool c<T> = true;
29 template<typename T>
30 bool d = false;
32 template<typename T>
33 bool d<T> = true; // expected-error{{variable template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}}
35 template<typename T> requires C1<T>
36 bool e = false;
38 template<typename T>
39 bool e<T> = true; // expected-error{{variable template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}}
41 template<typename T>
42 constexpr int f = 1;
44 template<typename T> requires C1<T> && C2<T>
45 constexpr int f<T> = 2;
47 template<typename T> requires C1<T> || C2<T>
48 constexpr int f<T> = 3;
50 static_assert(f<unsigned> == 2);
51 static_assert(f<char[10]> == 3);
52 static_assert(f<char> == 1);
54 template <int I>
55 struct S {
56 template <typename T>
57 static constexpr int f = 1;
59 template <typename T>
60 requires C1<T> && C2<T>
61 static constexpr int f<T> = 2;
63 template <typename T>
64 requires C1<T> || C2<T>
65 static constexpr int f<T> = 3;
68 static_assert(S<1>::f<unsigned> == 2);
69 static_assert(S<1>::f<char[10]> == 3);
70 static_assert(S<1>::f<char> == 1);