brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 2619524 Raw
76 lines · cpp
1// RUN: %clang_cc1 -std=c++26 %s -verify2 3namespace hana_enable_if_idiom {4  template<bool> struct A {};5  template<typename, typename = A<true>> struct B;6  template<typename T, bool N> struct B<T, A<N>> {};7  template<typename T> struct B<T, A<T::value>> {};8  struct C {9    static const bool value = true;10  };11  B<C> b;12}13 14namespace GH132562 {15  struct I {16    int v = 0;17  };18 19  namespace t1 {20    template <I... X> struct A;21    template <I... X>22      requires ((X.v == 0) ||...)23    struct A<X...>;24  } // namespace t125  namespace t2 {26    template <I... X> struct A; // expected-note {{template is declared here}}27    template <int... X> struct A<X...>;28    // expected-error@-1 {{is not more specialized than the primary template}}29    // expected-note@-2 {{no viable conversion from 'int' to 'I'}}30 31    template <int... X> struct B; // expected-note {{template is declared here}}32    template <I... X> struct B<X...>;33    // expected-error@-1 {{is not more specialized than the primary template}}34    // expected-note@-2 {{value of type 'const I' is not implicitly convertible to 'int'}}35  } // namespace t236  namespace t3 {37    struct J {38      int v = 0;39      constexpr J(int v) : v(v) {}40    };41    template <J... X> struct A;42    template <int... X> struct A<X...>;43 44    template <int... X> struct B; // expected-note {{template is declared here}}45    template <J... X> struct B<X...>;46    // expected-error@-1 {{is not more specialized than the primary template}}47    // expected-note@-2 {{value of type 'const J' is not implicitly convertible to 'int'}}48  } // namespace t349} // namespace GH13256250 51namespace GH51866 {52 53template <class> struct Trait;54template <class T>55    requires T::one56struct Trait<T> {}; // #gh51866-one57template <class T>58    requires T::two59struct Trait<T> {}; // #gh51866-two60 61struct Y {62    static constexpr bool one = true;63    static constexpr bool two = true;64};65 66template <class T>67concept C = sizeof(Trait<T>) != 0;68 69static_assert(!C<Y>);70 71Trait<Y> t;72// expected-error@-1{{ambiguous partial specializations of 'Trait<GH51866::Y>'}}73// expected-note@#gh51866-one{{partial specialization matches}}74// expected-note@#gh51866-two{{partial specialization matches}}75}76