brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · de4a484 Raw
37 lines · cpp
1// RUN:  %clang_cc1 -std=c++2a -verify %s2 3template<typename T, typename U>4constexpr bool is_same_v = false;5 6template<typename T>7constexpr bool is_same_v<T, T> = true;8 9template<typename T, typename U>10concept same_as = is_same_v<T, U>; //#is_same_v11 12template<typename T, typename... Us>13concept either = (is_same_v<T, Us> || ...);14 15template<typename... Ts>16struct T {17    template<same_as<Ts>... Us>18    // expected-note@-1{{because 'same_as<int, bool>' evaluated to false}}19    // expected-note@#is_same_v{{because 'is_same_v<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}}23 24    template<typename... Us>25    struct S {26        template<either<Ts, Us...>... Vs>27        static void foo(Vs... v);28    };29};30 31int 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);36}37