1*a76e68c9SSam McCall template <typename T, typename U> concept convertible_to = true; 2*a76e68c9SSam McCall template <typename T, typename U> concept same_as = true; 3*a76e68c9SSam McCall template <typename T> concept integral = true; 4*a76e68c9SSam McCall 5*a76e68c9SSam McCall template <typename A, typename B> 6*a76e68c9SSam McCall concept W = requires(A a, B b) { 7*a76e68c9SSam McCall { b.www } noexcept -> integral; 8*a76e68c9SSam McCall }; 9*a76e68c9SSam McCall 10*a76e68c9SSam McCall template <typename T> concept X = requires(T t) { 11*a76e68c9SSam McCall t.xxx(42); 12*a76e68c9SSam McCall typename T::xxx_t; 13*a76e68c9SSam McCall T::xyz::member; 14*a76e68c9SSam McCall }; 15*a76e68c9SSam McCall 16*a76e68c9SSam McCall template <typename T, typename U> 17*a76e68c9SSam McCall concept Y = requires(T t, U u) { t.yyy(u); }; 18*a76e68c9SSam McCall 19*a76e68c9SSam McCall template <typename T> 20*a76e68c9SSam McCall concept Z = requires(T t) { 21*a76e68c9SSam McCall { t.zzz() } -> same_as<int>; 22*a76e68c9SSam McCall requires W<int, T>; 23*a76e68c9SSam McCall }; 24*a76e68c9SSam McCall 25*a76e68c9SSam McCall // Concept constraints in all three slots require X, Y, Z, and ad-hoc stuff. 26*a76e68c9SSam McCall template <X T> 27*a76e68c9SSam McCall requires Y<T, int> && requires(T *t) { { t->aaa() } -> convertible_to<double>; } 28*a76e68c9SSam McCall void foo(T t) requires Z<T> || requires(T &t) { t.bbb(); t->bb(); } { 29*a76e68c9SSam McCall t.x; 30*a76e68c9SSam McCall t->x; 31*a76e68c9SSam McCall T::x; 32*a76e68c9SSam McCall 33*a76e68c9SSam McCall // RUN: %clang_cc1 -std=c++2a -code-completion-with-fixits -code-completion-at=%s:29:5 %s \ 34*a76e68c9SSam McCall // RUN: | FileCheck %s -check-prefix=DOT -implicit-check-not=xxx_t 35*a76e68c9SSam McCall // DOT: Pattern : [#convertible_to<double>#]aaa() 36*a76e68c9SSam McCall // DOT: Pattern : bb() (requires fix-it: {{.*}} to "->") 37*a76e68c9SSam McCall // DOT: Pattern : bbb() 38*a76e68c9SSam McCall // DOT: Pattern : [#integral#]www 39*a76e68c9SSam McCall // DOT: Pattern : xxx(<#int#>) 40*a76e68c9SSam McCall // FIXME: it would be nice to have int instead of U here. 41*a76e68c9SSam McCall // DOT: Pattern : yyy(<#U#>) 42*a76e68c9SSam McCall // DOT: Pattern : [#int#]zzz() 43*a76e68c9SSam McCall 44*a76e68c9SSam McCall // RUN: %clang_cc1 -std=c++2a -code-completion-with-fixits -code-completion-at=%s:30:6 %s \ 45*a76e68c9SSam McCall // RUN: | FileCheck %s -check-prefix=ARROW -implicit-check-not=xxx_t 46*a76e68c9SSam McCall // ARROW: Pattern : [#convertible_to<double>#]aaa() (requires fix-it: {{.*}} to ".") 47*a76e68c9SSam McCall // ARROW: Pattern : bb() 48*a76e68c9SSam McCall // ARROW: Pattern : bbb() (requires fix-it 49*a76e68c9SSam McCall // ARROW: Pattern : [#integral#]www (requires fix-it 50*a76e68c9SSam McCall // ARROW: Pattern : xxx(<#int#>) (requires fix-it 51*a76e68c9SSam McCall // ARROW: Pattern : yyy(<#U#>) (requires fix-it 52*a76e68c9SSam McCall // ARROW: Pattern : [#int#]zzz() (requires fix-it 53*a76e68c9SSam McCall 54*a76e68c9SSam McCall // RUN: %clang_cc1 -std=c++2a -code-completion-with-fixits -code-completion-at=%s:31:6 %s \ 55*a76e68c9SSam McCall // RUN: | FileCheck %s -check-prefix=COLONS -implicit-check-not=yyy 56*a76e68c9SSam McCall // COLONS: Pattern : xxx_t 57*a76e68c9SSam McCall // COLONS: Pattern : xyz 58*a76e68c9SSam McCall } 59*a76e68c9SSam McCall 60