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