brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 64aad24 Raw
60 lines · cpp
1template <typename T, typename U> concept convertible_to = true;2template <typename T, typename U> concept same_as = true;3template <typename T> concept integral = true;4 5template <typename A, typename B>6concept W = requires(A a, B b) {7  { b.www } noexcept -> integral;8};9 10template <typename T> concept X = requires(T t) {11  t.xxx(42);12  typename T::xxx_t;13  T::xyz::member;14};15 16template <typename T, typename U>17concept Y = requires(T t, U u) { t.yyy(u); };18 19template <typename T>20concept 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.26template <X T>27requires Y<T, int> && requires(T *t) { { t->aaa() } -> convertible_to<double>; }28void 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_t35  // DOT: Pattern : [#convertible_to<double>#]aaa()36  // DOT: Pattern : bb() (requires fix-it: {{.*}} to "->")37  // DOT: Pattern : bbb()38  // DOT: Pattern : [#integral#]www39  // 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_t46  // ARROW: Pattern : [#convertible_to<double>#]aaa() (requires fix-it: {{.*}} to ".")47  // ARROW: Pattern : bb()48  // ARROW: Pattern : bbb() (requires fix-it49  // ARROW: Pattern : [#integral#]www (requires fix-it50  // ARROW: Pattern : xxx(<#int#>) (requires fix-it51  // ARROW: Pattern : yyy(<#U#>) (requires fix-it52  // ARROW: Pattern : [#int#]zzz() (requires fix-it53 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=yyy56  // COLONS: Pattern : xxx_t57  // COLONS: Pattern : xyz58}59 60