brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.3 KiB · 8e3b1b6 Raw
106 lines · cpp
1// RUN: %clang_cc1 -std=c++20 -verify %s2 3template<class T> struct S {4    template<class U> struct N {5        N(T) {}6        N(T, U) {}7        template<class V> N(V, U) {}8    };9};10 11S<int>::N x{"a", 1};12using T = decltype(x);13using T = S<int>::N<int>;14 15template<class X> struct default_ftd_argument {16    template<class Y> struct B {17        template<class W = X, class Z = Y, class V = Z, int I = 0> B(Y);18    };19};20 21default_ftd_argument<int>::B default_arg("a");22using DefaultArg = decltype(default_arg);23using DefaultArg = default_ftd_argument<int>::B<const char *>;24 25template<bool> struct test;26template<class X> struct non_type_param {27    template<class Y> struct B {28        B(Y);29        template<class Z, test<Z::value> = 0> B(Z);30    };31};32 33non_type_param<int>::B ntp = 5;34using NonTypeParam = decltype(ntp);35using NonTypeParam = non_type_param<int>::B<int>;36 37template<typename A, typename T>38concept True = true;39 40template<typename T>41concept False = false; // #False42 43template<class X> struct concepts {44    template<class Y> struct B {45        template<class K = X, True<K> Z> B(Y, Z);46    };47};48 49concepts<int>::B cc(1, 3);50using Concepts = decltype(cc);51using Concepts = concepts<int>::B<int>;52 53template<class X> struct requires_clause {54    template<class Y> struct B {55        template<class Z> requires true56            B(Y, Z);57    };58};59 60requires_clause<int>::B req(1, 2);61using RC = decltype(req);62using RC = requires_clause<int>::B<int>;63 64template<typename X> struct nested_init_list {65    template<True<X> Y>66    struct B {67        X x;68        Y y;69    };70 71    template<False F>  // #INIT_LIST_INNER_INVALID_HEADER72    struct concept_fail { // #INIT_LIST_INNER_INVALID73        X x;74        F f;75    };76};77 78nested_init_list<int>::B nil {1, 2};79using NIL = decltype(nil);80using NIL = nested_init_list<int>::B<int>;81 82// expected-error@+1 {{no viable constructor or deduction guide for deduction of template arguments of 'nested_init_list<int>::concept_fail'}}83nested_init_list<int>::concept_fail nil_invalid{1, ""};84// expected-note@#INIT_LIST_INNER_INVALID {{candidate template ignored: constraints not satisfied [with F = const char *]}}85// expected-note@#INIT_LIST_INNER_INVALID_HEADER {{because 'const char *' does not satisfy 'False'}}86// expected-note@#False {{because 'false' evaluated to false}}87// expected-note@#INIT_LIST_INNER_INVALID {{implicit deduction guide declared as 'template <False F> concept_fail(int, F) -> nested_init_list<int>::concept_fail<F>'}}88// expected-note@#INIT_LIST_INNER_INVALID {{candidate function template not viable: requires 1 argument, but 2 were provided}}89// expected-note@#INIT_LIST_INNER_INVALID {{implicit deduction guide declared as 'template <False F> concept_fail(nested_init_list<int>::concept_fail<F>) -> nested_init_list<int>::concept_fail<F>'}}90// expected-note@#INIT_LIST_INNER_INVALID {{candidate function template not viable: requires 0 arguments, but 2 were provided}}91// expected-note@#INIT_LIST_INNER_INVALID {{implicit deduction guide declared as 'template <False F> concept_fail() -> nested_init_list<int>::concept_fail<F>'}}92 93namespace GH88142 {94 95template <typename, typename...> struct X {96  template <typename> struct Y {97    template <typename T> Y(T) {}98  };99 100  template <typename T> Y(T) -> Y<T>;101};102 103X<int>::Y y(42);104 105} // namespace PR88142106