1 // RUN: %clang_cc1 -std=c++20 -verify %s
2 // RUN: %clang_cc1 -std=c++20 -verify %s -triple powerpc64-ibm-aix
9 auto f
= []() requires c
<void> {
22 auto f
= [](auto... args
) requires c
<T
> {
26 auto f2
= [](auto... args
)
27 requires (sizeof...(args
) > 0)
37 template<class> concept C
= true;
38 template<int> constexpr bool v
= [](C
auto) { return true; }(0);
42 template<class> concept C
= true;
43 template<int> constexpr bool v
= [](C
auto...) { return true; }(0);
52 auto f
= [](any
auto) {
55 using function_ptr
= void(*)(int);
56 function_ptr ptr
= f
<void>;
59 // GH58368: A lambda defined in a concept requires we store
60 // the concept as a part of the lambda context.
61 namespace LambdaInConcept
{
62 using size_t = unsigned long;
67 template <class T
, class... Ts
>
68 concept NotLike
= true;
70 template <size_t, class... Ts
>
72 template <NotLike
<Ts
...> T
> operator T
&() const;
73 template <NotLike
<Ts
...> T
> operator T
&&() const;
77 concept ConstructibleWithN
= (requires
{
78 []<size_t I
, size_t... Idxs
>
80 requires requires
{ T
{AnyExcept
<I
, T
>{}}; }
91 static_assert(ConstructibleWithN
<Foo
>);
95 template <typename It
>
96 inline constexpr It
declare ();
98 template <typename It
, template <typename
> typename Template
>
99 concept D
= requires
{
100 { [] <typename T1
> (Template
<T1
> &) {}(declare
<It
&>()) };
103 template <typename T
>
106 template <typename T
>
110 struct Adapter
<T
> {};
112 template struct Adapter
<B
<int>>;
114 } // namespace GH56556
119 concept C
= requires(T t
) {
120 requires
requires (T u
) {
122 return requires(V v
) {
129 template <class From
>
134 static F
create(F from
) {
145 // https://github.com/llvm/llvm-project/issues/49570#issuecomment-1664966972
146 Widget
<char>::create(0);
149 } // namespace GH82849
153 // GH60642 reported an assert being hit, make sure we don't assert.
155 template<auto Q
> concept C
= requires
{ Q
.template operator()<float>(); };
156 template<class> concept D
= true;
157 static_assert(C
<[]<D
>{}>); // ok
158 template<class> concept E
= C
<[]<D
>{}>;
159 static_assert(E
<int>); // previously Asserted.
161 // ensure we properly diagnose when "D" is false.
163 template<auto Q
> concept C
= requires
{ Q
.template operator()<float>(); };
164 template<class> concept D
= false;
165 static_assert(C
<[]<D
>{}>);
166 // expected-error@-1{{static assertion failed}}
167 // expected-note@-2{{does not satisfy 'C'}}
168 // expected-note@-5{{because 'Q.template operator()<float>()' would be invalid: no matching member function for call to 'operator()'}}
169 template<class> concept E
= C
<[]<D
>{}>;
170 static_assert(E
<int>);
171 // expected-error@-1{{static assertion failed}}
172 // expected-note@-2{{because 'int' does not satisfy 'E'}}
173 // expected-note@-4{{does not satisfy 'C'}}
174 // expected-note@-11{{because 'Q.template operator()<float>()' would be invalid: no matching member function for call to 'operator()'}}
178 namespace ReturnTypeRequirementInLambda
{
179 template <typename T
>
184 return requires(T t
) {
189 static_assert(test
<int>);
191 template <typename T
>
194 int f1() { return 1; }
198 auto make_caller
= []<auto member
> {
200 if constexpr (requires
{
201 { (ps
->*member
)() } -> C2
;
207 auto caller
= make_caller
.operator()<&S1::f1
>();
209 } // namespace ReturnTypeRequirementInLambda
216 return [](auto obj
, auto... params
)
220 return sizeof...(pack
);
223 { return false; }(y
);
227 } // namespace GH73418
235 concept D
= []<C T
= int>() { return true; }();
239 } // namespace GH93821
241 namespace dependent_param_concept
{
242 template <typename
... Ts
> void sink(Ts
...) {}
243 void dependent_param() {
244 auto L
= [](auto... x
) {
245 return [](decltype(x
)... y
) {
247 requires requires
{ sink(y
..., z
); }
253 } // namespace dependent_param_concept
255 namespace init_captures
{
256 template <int N
> struct V
{};
258 void sink(V
<0>, V
<1>, V
<2>, V
<3>, V
<4>) {}
260 void init_capture_pack() {
261 auto L
= [](auto... z
) {
262 return [=](auto... y
) {
263 return [... w
= z
, y
...](auto)
264 requires requires
{ sink(w
..., y
...); }
268 L(V
<0>{}, V
<1>{}, V
<2>{})(V
<3>{}, V
<4>{})(1);
271 void dependent_capture_packs() {
272 auto L
= [](auto... z
) {
273 return [... w
= z
](auto... y
) {
274 return [... c
= w
](auto)
275 requires requires
{ sink(c
..., y
...); }
279 L(V
<0>{}, V
<1>{}, V
<2>{})(V
<3>{}, V
<4>{})(1);
281 } // namespace init_captures