// RUN: %clang_cc1 -std=c++20 -verify %s namespace PR47043 { template concept True = true; template concept AllTrue1 = True; // expected-error {{expression contains unexpanded parameter pack 'T'}} template concept AllTrue2 = (True && ...); template concept AllTrue3 = (bool)(True & ...); static_assert(AllTrue2); static_assert(AllTrue3); } namespace PR47025 { template concept AllAddable1 = requires(T ...t) { (void(t + 1), ...); }; template concept AllAddable2 = (requires(T ...t) { (t + 1); } && ...); // expected-error {{requirement contains unexpanded parameter pack 't'}} template concept AllAddable3 = (requires(T t) { (t + 1); } && ...); template concept AllAddable4 = requires(T t) { (t + 1); }; // expected-error {{expression contains unexpanded parameter pack 'T'}} template concept AllAddable5 = requires(T t) { (void(t + 1), ...); }; // expected-error {{does not contain any unexpanded}} template concept AllAddable6 = (requires { (T() + 1); } && ...); template concept AllAddable7 = requires { (T() + 1); }; // expected-error {{expression contains unexpanded parameter pack 'T'}} static_assert(AllAddable1); static_assert(AllAddable3); static_assert(AllAddable6); static_assert(!AllAddable1); static_assert(!AllAddable3); static_assert(!AllAddable6); } namespace PR45699 { template concept C = true; // expected-note 2{{here}} template void f1a() requires C; // expected-error {{requires clause contains unexpanded parameter pack 'Ts'}} template requires C void f1b(); // expected-error {{requires clause contains unexpanded parameter pack 'Ts'}} template void f2a() requires (C && ...); template requires (C && ...) void f2b(); template void f3a() requires C; // expected-error {{pack expansion used as argument for non-pack parameter of concept}} template requires C void f3b(); // expected-error {{pack expansion used as argument for non-pack parameter of concept}} template void f4() { ([] () requires C {} ()); // expected-error {{expression contains unexpanded parameter pack 'Ts'}} ([] requires C () {} ()); // expected-error {{expression contains unexpanded parameter pack 'Ts'}} } template void f5() { ([] () requires C {} (), ...); ([] requires C () {} (), ...); } void g() { f1a(); f1b(); // FIXME: Bad error recovery. expected-error {{undeclared identifier}} f2a(); f2b(); f3a(); f3b(); // FIXME: Bad error recovery. expected-error {{undeclared identifier}} f4(); f5(); } } namespace P0857R0 { template static constexpr bool V = true; void f() { auto x = [] requires B {}; // expected-note {{constraints not satisfied}} expected-note {{false}} x.operator()(); x.operator()(); // expected-error {{no matching member function}} auto y = [] requires V () {}; y.operator()(); // OK } template concept C = true; template requires C typename U> struct X {}; template requires C struct Y {}; X xy; } namespace PR50306 { template concept NotInt = sizeof(T) != sizeof(int); // expected-note {{because}} template void f() { [](NotInt auto) {}(T()); // expected-error {{no matching function}} expected-note {{constraints not satisfied}} expected-note {{because}} } template void f(); // OK template void f(); // expected-note {{in instantiation of}} } namespace PackInTypeConstraint { template concept C = sizeof(T) == sizeof(int); // expected-note 3{{}} template U> void h1(); // expected-error {{type constraint contains unexpanded parameter pack 'T'}} template ...U> void h2(); template void h3(C auto); // expected-error {{type constraint contains unexpanded parameter pack 'T'}} template void h4(C auto...); template void f1() { [] U>(U u){}(T()); // expected-error {{unexpanded parameter pack 'T'}} } template void f2() { ([] U>(U u){}(T()), ...); // expected-error {{no match}} expected-note 2{{}} } template void f2(); // OK template void f2(); // expected-note {{in instantiation of}} void f3() { ([] U>(U u){}(0), // expected-error {{type constraint contains unexpanded parameter pack 'T'}} ...); // expected-error {{does not contain any unexpanded}} } template void g1() { [](C auto){}(T()); // expected-error {{expression contains unexpanded parameter pack 'T'}} } template void g2() { ([](C auto){}(T()), ...); // expected-error {{no matching function}} expected-note {{constraints not satisfied}} expected-note {{because}} } template void g2(); // OK template void g2(); // expected-note {{in instantiation of}} void g3() { ([](C auto){}(1), // expected-error {{type constraint contains unexpanded parameter pack 'T'}} ...); // expected-error {{does not contain any unexpanded}} } template void g4() { []() -> C auto{ return T(); }(); // expected-error {{expression contains unexpanded parameter pack 'T'}} } template void g5() { ([]() -> C auto{ // expected-error-re {{deduced type {{.*}} does not satisfy}} expected-note {{while substituting into a lambda}} return T(); }(), ...); } template void g5(); // OK template void g5(); // expected-note {{in instantiation of}} void g6() { ([]() -> C auto{ // expected-error {{declaration type contains unexpanded parameter pack 'T'}} return T(); // expected-error {{expression contains unexpanded parameter pack 'T'}} }(), ...); // expected-error {{does not contain any unexpanded}} } } namespace BuiltinIsConstantEvaluated { // Check that we do all satisfaction and diagnostic checks in a constant context. template concept C = __builtin_is_constant_evaluated(); // expected-warning {{always}} static_assert(C); template concept D = __builtin_is_constant_evaluated() == true; // expected-warning {{always}} static_assert(D); template concept E = __builtin_is_constant_evaluated() == true && // expected-warning {{always}} false; // expected-note {{'false' evaluated to false}} static_assert(E); // expected-error {{failed}} expected-note {{because 'int' does not satisfy 'E'}} template concept F = __builtin_is_constant_evaluated() == false; // expected-warning {{always}} // expected-note@-1 {{'__builtin_is_constant_evaluated() == false' (1 == 0)}} static_assert(F); // expected-error {{failed}} expected-note {{because 'int' does not satisfy 'F'}} template concept G = __builtin_is_constant_evaluated() && // expected-warning {{always}} false; // expected-note {{'false' evaluated to false}} static_assert(G); // expected-error {{failed}} expected-note {{because 'int' does not satisfy 'G'}} } namespace NoConstantFolding { // Ensure we use strict constant evaluation rules when checking satisfaction. int n; template concept C = &n + 3 - 3 == &n; // expected-error {{non-constant expression}} expected-note {{cannot refer to element 3 of non-array object}} static_assert(C); // expected-note {{while checking}} } namespace PR50337 { template concept foo = true; template concept foo2 = foo && true; void f(foo auto, auto); void f(foo2 auto, auto); void g() { f(1, 2); } } namespace PR50561 { template concept C = false; template void f(T, U); template void f(T, U) = delete; void g() { f(0, 0); } } namespace PR49188 { template concept C = false; // expected-note 7 {{because 'false' evaluated to false}} C auto f1() { // expected-error {{deduced type 'void' does not satisfy 'C'}} return void(); } C auto f2() { // expected-error {{deduced type 'void' does not satisfy 'C'}} return; } C auto f3() { // expected-error {{deduced type 'void' does not satisfy 'C'}} } C decltype(auto) f4() { // expected-error {{deduced type 'void' does not satisfy 'C'}} return void(); } C decltype(auto) f5() { // expected-error {{deduced type 'void' does not satisfy 'C'}} return; } C decltype(auto) f6() { // expected-error {{deduced type 'void' does not satisfy 'C'}} } C auto& f7() { // expected-error {{deduced type 'void' does not satisfy 'C'}} return void(); } C auto& f8() { return; // expected-error {{cannot deduce return type 'C auto &' from omitted return expression}} } C auto& f9() { // expected-error {{cannot deduce return type 'C auto &' for function with no return statements}} } } namespace PR53911 { template concept C = false; // expected-note 3 {{because 'false' evaluated to false}} C auto *f1() { // expected-error {{deduced type 'void' does not satisfy 'C'}} return (void*)nullptr; } C auto *f2() { // expected-error {{deduced type 'int' does not satisfy 'C'}} return (int*)nullptr; } C auto *****f3() { // expected-error {{deduced type 'int' does not satisfy 'C'}} return (int*****)nullptr; } } namespace PR54379 { template struct A { static void f() requires (N == 0) { return; } // expected-note {{candidate template ignored: constraints not satisfied}} expected-note {{evaluated to false}} static void f() requires (N == 1) { return; } // expected-note {{candidate template ignored: constraints not satisfied}} expected-note {{evaluated to false}} }; void (*f1)() = A<2>::f; // expected-error {{address of overloaded function 'f' does not match required type}} struct B { template static void f() requires (N2 == 0) { return; } // expected-note {{candidate template ignored: constraints not satisfied [with N2 = 1]}} expected-note {{evaluated to false}} }; void (*f2)() = B::f; // expected-error {{address of overloaded function 'f' does not match required type}} } namespace PR54443 { template struct is_same { static constexpr bool value = false; }; template struct is_same { static constexpr bool value = true; }; template concept same_as = is_same::value; // expected-note-re 4 {{because {{.*}} evaluated to false}} int const &f(); same_as auto i1 = f(); // expected-error {{deduced type 'int' does not satisfy 'same_as'}} same_as auto &i2 = f(); same_as auto &&i3 = f(); // expected-error {{deduced type 'const int &' does not satisfy 'same_as'}} same_as auto i4 = f(); // expected-error {{deduced type 'int' does not satisfy 'same_as'}} same_as auto &i5 = f(); // expected-error {{deduced type 'const int' does not satisfy 'same_as'}} same_as auto &&i6 = f(); template concept C = false; // expected-note 3 {{because 'false' evaluated to false}} int **const &g(); C auto **j1 = g(); // expected-error {{deduced type 'int' does not satisfy 'C'}} C auto **&j2 = g(); // expected-error {{deduced type 'int' does not satisfy 'C'}} C auto **&&j3 = g(); // expected-error {{deduced type 'int' does not satisfy 'C'}} } namespace GH55567 { template class> concept C = true; template struct S {}; void f(C auto); } // namespace GH55567 namespace SubConstraintChecks { template concept TrueConstraint = true; template concept FalseConstraint = false; template class ContainsConstrainedFuncTrue { public: template static void func(V &&, Constrained &&C); }; template class ContainsConstrainedFuncFalse { public: template static void func(V &&, Constrained &&C); }; template concept TrueConstraint2 = requires(float &&t) { ContainsConstrainedFuncTrue::func(5, 0.0); }; template concept FalseConstraint2 = requires(float &&t) { ContainsConstrainedFuncFalse::func(5, 0.0); // #FC2_CONSTR }; template void useTrue(int F) requires TrueConstraint2 {} template void useFalse(int F) // #USE_FALSE requires FalseConstraint2 // #USE_FALSE_CONSTR {} // Should only diagnose 'false' once instantiated. void UseUse() { useTrue(5); useFalse(5); // expected-error@-1{{no matching function for call to 'useFalse'}} // expected-note@#USE_FALSE{{constraints not satisfied}} // expected-note@#USE_FALSE_CONSTR{{because 'int' does not satisfy 'FalseConstraint2'}} // expected-note@#FC2_CONSTR {{would be invalid: no matching function for call to 'func'}} } } // namespace SubConstraintChecks namespace DeducedTemplateArgs { template struct ItrTraits { template struct Ptr { }; template requires requires { typename PtrItr::pointer; } struct Ptr { using type = typename Itr::pointer; }; using pointer = typename Ptr::type; // #TRAITS_PTR }; struct complete_itr { using pointer = int; }; template class Complete { using ItrType = ItrTraits; ItrType begin() noexcept { return ItrType(); } }; // This version doesn't have 'pointer', so error confirms we are in the first // verison of 'Ptr'. struct not_complete_itr { }; template class NotComplete { using ItrType = ItrTraits; ItrType begin() noexcept { return ItrType(); } // expected-error@#TRAITS_PTR{{no type named 'type' in }} // expected-note@-2{{in instantiation of template class }} }; } // namespace DeducedTemplateArgs namespace DeferredInstantiationInstScope { template struct remove_ref { using type = T; }; template struct remove_ref { using type = T; }; template struct remove_ref { using type = T; }; template constexpr bool IsInt = PR54443::is_same::type, int>::value; template void SingleDepthReferencesTop(U &&u) { struct lc { void operator()() // #SDRT_OP requires IsInt // #SDRT_REQ {} }; lc lv; lv(); // #SDRT_CALL } template void SingleDepthReferencesTopNotCalled(U &&u) { struct lc { void operator()() requires IsInt {} }; lc lv; } template void SingleDepthReferencesTopCalled(U &&u) { struct lc { void operator()() // #CALLOP requires IsInt // #CONSTR {} }; lc lv; lv(); // expected-error@-1{{no matching function for call to object of type 'lc'}} // expected-note@#SDRTC{{in instantiation of function template}} // expected-note@#CALLOP{{constraints not satisfied}} // expected-note@#CONSTR{{substituted constraint expression is ill-formed}} } template void SingleDepthReferencesTopLambda(U &&u) { []() // #SDRTL_OP requires IsInt // #SDRTL_REQ {}(); } template void DoubleDepthReferencesTop(U &&u) { struct lc { // #DDRT_STRCT void operator()() { struct lc2 { void operator()() // #DDRT_OP requires IsInt // #DDRT_REQ {} }; lc2 lv2; lv2(); // #DDRT_CALL } }; lc lv; lv(); } template void DoubleDepthReferencesTopLambda(U &&u) { []() { []() // #DDRTL_OP requires IsInt // #DDRTL_REQ {}(); }(); } template void DoubleDepthReferencesAll(U &&u) { struct lc { // #DDRA_STRCT void operator()(U &&u2) { struct lc2 { void operator()(U &&u3) // #DDRA_OP requires IsInt && // #DDRA_REQ IsInt && IsInt {} }; lc2 lv2; lv2(u2); // #DDRA_CALL } }; lc lv; lv(u); } template void DoubleDepthReferencesAllLambda(U &&u) { [](U &&u2) { // #DDRAL_OP1 [](U && u3) // #DDRAL_OP2 requires IsInt // #DDRAL_REQ && IsInt && IsInt {}(u2); }(u); } template struct CausesFriendConstraint { template friend void FriendFunc(CausesFriendConstraint, V) // #FF_DECL requires IsInt && IsInt // #FF_REQ {} }; // FIXME: Re-enable this test when constraints are allowed to refer to captures. // template // void ChecksCapture(T x) { // [y = x]() requires(IsInt){}(); // } template void ChecksLocalVar(T x) { T Local; []() // #CLV_OP requires(IsInt) // #CLV_REQ {}(); } template void LocalStructMemberVar(T x) { struct S { T local; void foo() requires(IsInt) // #LSMV_REQ {} } s; s.foo(); // #LSMV_CALL }; template struct ChecksMemberVar { T t; void foo() requires(IsInt) // #CMV_FOO {} template void foo2() // #CMV_FOO2 requires(IsInt) // #CMV_FOO2_REQ {} }; void test_dependent() { int v = 0; float will_fail; SingleDepthReferencesTop(v); SingleDepthReferencesTop(will_fail); // expected-error@#SDRT_CALL{{no matching function for call to object of type 'lc'}} // expected-note@-2{{in instantiation of function template specialization}} // expected-note@#SDRT_OP{{candidate function not viable}} // expected-note@#SDRT_REQ{{'IsInt' evaluated to false}} SingleDepthReferencesTopNotCalled(v); // Won't error unless we try to call it. SingleDepthReferencesTopNotCalled(will_fail); SingleDepthReferencesTopCalled(v); // #SDRTC SingleDepthReferencesTopLambda(v); SingleDepthReferencesTopLambda(will_fail); // expected-note@-1{{in instantiation of function template specialization}} // expected-error@#SDRTL_OP{{no matching function for call to object of type}} // expected-note@#SDRTL_OP{{candidate function not viable: constraints not satisfied}} // expected-note@#SDRTL_REQ{{because 'IsInt' evaluated to false}} DoubleDepthReferencesTop(v); DoubleDepthReferencesTop(will_fail); // expected-error@#DDRT_CALL{{no matching function for call to object of type 'lc2'}} // expected-note@-2{{in instantiation of function template specialization}} // expected-note@#DDRT_STRCT{{in instantiation of member function}} // expected-note@#DDRT_OP{{candidate function not viable}} // expected-note@#DDRT_REQ{{'IsInt' evaluated to false}} DoubleDepthReferencesTopLambda(v); DoubleDepthReferencesTopLambda(will_fail); // expected-note@-1{{in instantiation of function template specialization}} // expected-error@#DDRTL_OP{{no matching function for call to object of type}} // expected-note@#DDRTL_OP{{candidate function not viable: constraints not satisfied}} // expected-note@#DDRTL_OP{{while substituting into a lambda expression here}} // expected-note@#DDRTL_REQ{{because 'IsInt' evaluated to false}} DoubleDepthReferencesAll(v); DoubleDepthReferencesAll(will_fail); // expected-error@#DDRA_CALL{{no matching function for call to object of type 'lc2'}} // expected-note@-2{{in instantiation of function template specialization}} // expected-note@#DDRA_STRCT{{in instantiation of member function}} // expected-note@#DDRA_OP{{candidate function not viable}} // expected-note@#DDRA_REQ{{'IsInt' evaluated to false}} DoubleDepthReferencesAllLambda(v); DoubleDepthReferencesAllLambda(will_fail); // expected-note@-1{{in instantiation of function template specialization}} // expected-note@#DDRAL_OP1{{while substituting into a lambda expression here}} // expected-error@#DDRAL_OP2{{no matching function for call to object of type}} // expected-note@#DDRAL_OP2{{candidate function not viable: constraints not satisfied}} // expected-note@#DDRAL_REQ{{because 'IsInt' evaluated to false}} CausesFriendConstraint CFC; FriendFunc(CFC, 1); FriendFunc(CFC, 1.0); // expected-error@-1{{no matching function for call to 'FriendFunc'}} // expected-note@#FF_DECL{{constraints not satisfied}} // expected-note@#FF_REQ{{because 'IsInt' evaluated to false}} // FIXME: Re-enable this test when constraints are allowed to refer to captures. // ChecksCapture(v); ChecksLocalVar(v); ChecksLocalVar(will_fail); // expected-note@-1{{in instantiation of function template specialization}} // expected-error@#CLV_OP{{no matching function for call to object of type}} // expected-note@#CLV_OP{{candidate function not viable: constraints not satisfied}} // expected-note@#CLV_REQ{{because 'IsInt' evaluated to false}} LocalStructMemberVar(v); LocalStructMemberVar(will_fail); // expected-error@#LSMV_CALL{{invalid reference to function 'foo'}} // expected-note@-2{{in instantiation of function template specialization}} // expected-note@#LSMV_REQ{{because 'IsIntlocal)>' evaluated to false}} ChecksMemberVar CMV; CMV.foo(); CMV.foo2(); ChecksMemberVar CMV2; CMV2.foo(); // expected-error@-1{{invalid reference to function 'foo'}} // expected-note@#CMV_FOO{{because 'IsIntt)>' evaluated to false}} CMV2.foo2(); // expected-error@-1{{no matching member function for call to 'foo2'}} // expected-note@#CMV_FOO2{{constraints not satisfied}} // expected-note@#CMV_FOO2_REQ{{because 'IsIntt)>' evaluated to false}} } } // namespace DeferredInstantiationInstScope // Ane example of evaluating a concept at two different depths in the same // evaluation. No diagnostic is expected. namespace SameConceptDifferentDepth { template concept sentinel_for = requires(_Ip __i) { __i++; }; template concept bidirectional_iterator = sentinel_for<_Ip>; template class move_iterator { public: auto operator++(int) requires sentinel_for<_Iter>{} }; static_assert(bidirectional_iterator>); } // namespace SameConceptDifferentDepth namespace VarInit { template concept __can_reference = true; template class common_iterator { public: common_iterator() { constexpr auto x = requires(_Iter & __i) { { __i } -> __can_reference; }; } }; void test() { auto commonIter1 = common_iterator(); } } // namespace VarInit namespace InlineFriendOperator { template concept C = true; template class counted_iterator { _Iter I; public: constexpr counted_iterator() = default; friend constexpr auto operator+( // expected-note {{candidate function not viable}} int __n, const counted_iterator &__x) requires C { return __x + __n; // expected-error{{invalid operands to binary expression}} } }; constexpr bool test() { counted_iterator iter; auto x = 2 + iter; // expected-note{{in instantiation of member function 'InlineFriendOperator::operator+'}} return true; } } // namespace InlineFriendOperator namespace ClassTemplateInstantiation { struct Type; template < typename A, typename B, typename C> concept ConstraintF = false; // #ConstraintF template < typename A, typename B, typename C> concept ConstraintT = true; template < typename T > struct Parent { template < typename U, ConstraintT > struct ChildT{}; ChildT CauseInstT; template < typename U, ConstraintF > struct ChildF{};// #ChildF ChildF CauseInstF; //#CauseInstF }; // expected-error@#CauseInstF{{constraints not satisfied for class template}} // expected-note@+3{{in instantiation of template class}} // expected-note@#ChildF{{evaluated to false}} // expected-note@#ConstraintF{{because 'false' evaluated to false}} Parent Inst; } // namespace ClassTemplateInstantiation namespace SelfFriend { template concept Constraint = requires (T i) { (*i); }; template concept Constraint2 = requires (T i) { (*i); }; template struct Iterator { template friend class Iterator; void operator*(); }; template // #ITER_BAD struct IteratorBad { template //#ITER_BAD_FRIEND friend class IteratorBad; void operator*(); }; Iterator I; Iterator I2; IteratorBad I3; // expected-error@#ITER_BAD_FRIEND{{constraint differs}} // expected-note@-1{{in instantiation of template class}} // expected-note@#ITER_BAD{{previous template declaration}} } // namespace SelfFriend namespace Surrogates { int f1(int); template struct A { using F = int(int); operator F*() requires N { return f1; } // expected-note{{conversion candidate 'operator int (*)(int)' not viable: constraints not satisfied}} }; int i = A{}(0); int j = A{}(0); // expected-error{{no matching function for call to object of type 'A'}} } namespace ConstrainedMemberVarTemplate { template struct Container { static constexpr long arity = Size; template requires(sizeof(U) == arity) // #CMVT_REQ using var_templ = int; }; Container<4>::var_templ inst; Container<5>::var_templ inst_fail; // expected-error@-1{{constraints not satisfied for alias template 'var_templ'}} // expected-note@#CMVT_REQ{{because 'sizeof(int) == arity' (4 == 5) evaluated to false}} } // namespace ConstrainedMemberVarTemplate // These should not diagnose, where we were unintentionally doing so before by // checking trailing requires clause twice, yet not having the ability to the // 2nd time, since it was no longer a dependent variant. namespace InheritedFromPartialSpec { template constexpr bool Check = true; template struct Foo { template Foo(U&&) requires (Check){} template void MemFunc(U&&) requires (Check){} template static void StaticMemFunc(U&&) requires (Check){} ~Foo() requires (Check){} }; template<> struct Foo : Foo { using Foo::Foo; using Foo::MemFunc; using Foo::StaticMemFunc; }; void use() { Foo F {1.1}; F.MemFunc(1.1); Foo::StaticMemFunc(1.1); } template struct counted_iterator { constexpr auto operator->() const noexcept requires false { return T::Invalid; }; }; template concept __has_member_pointer = requires { typename _Ip::pointer; }; template struct __iterator_traits_member_pointer_or_arrow_or_void { using type = void; }; template<__has_member_pointer _Ip> struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { using type = typename _Ip::pointer; }; template requires requires(_Ip& __i) { __i.operator->(); } && (!__has_member_pointer<_Ip>) struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { using type = decltype(declval<_Ip&>().operator->()); }; void use2() { __iterator_traits_member_pointer_or_arrow_or_void> f; } }// namespace InheritedFromPartialSpec namespace GH48182 { template // expected-error{{template parameter pack must be the last template parameter}} concept invalid = true; template requires invalid // expected-error{{use of undeclared identifier 'invalid'}} no errors are printed ; static_assert(invalid also here ; // expected-error{{use of undeclared identifier 'invalid'}} int foo() { bool b; b = invalid not just in declarations; // expected-error{{expected ';' after expression}} // expected-error@-1{{use of undeclared identifier 'invalid'}} // expected-error@-2{{expected ';' after expression}} // expected-error@-3{{use of undeclared identifier 'just'}} // expected-error@-4{{unknown type name 'in'}} return b; } } // namespace GH48182 namespace GH61777 { template concept C = sizeof(T) == 4; // #61777_C template concept C2 = sizeof(T) == sizeof(U); //#61777_C2 template struct Parent { template struct TakesUnary { static const int i = 0 ; }; // #UNARY template auto> struct TakesBinary { static const int i = 0 ; }; //#BINARY }; static_assert(Parent::TakesUnary::i == 0); // expected-error@+3{{constraints not satisfied for class template 'TakesUnary'}} // expected-note@#UNARY{{because 'decltype(0ULL)' (aka 'unsigned long long') does not satisfy 'C'}} // expected-note@#61777_C{{because 'sizeof(unsigned long long) == 4' (8 == 4) evaluated to false}} static_assert(Parent::TakesUnary::i == 0); static_assert(Parent::TakesBinary::i == 0); // expected-error@+3{{constraints not satisfied for class template 'TakesBinary'}} // expected-note@#BINARY{{because 'C2' evaluated to false}} // expected-note@#61777_C2{{because 'sizeof(unsigned long long) == sizeof(int)' (8 == 4) evaluated to false}} static_assert(Parent::TakesBinary::i == 0); } namespace TemplateInsideNonTemplateClass { template concept C = true; template auto L = [] U>() {}; struct Q { template U> friend constexpr auto decltype(L)::operator()() const; }; template concept C1 = false; struct Foo { template struct Bar {}; template requires(C1) struct Bar; }; Foo::Bar BarInstance; } // namespace TemplateInsideNonTemplateClass namespace GH61959 { template concept C = (sizeof(T0) >= 4); template struct Orig { }; template struct Orig { template requires C void f() { } template requires true void f() { } }; template struct Mod {}; template struct Mod { template requires C constexpr static int f() { return 1; } template requires C constexpr static int f() { return 2; } }; static_assert(Mod::f() == 1); static_assert(Mod::f() == 2); template struct Outer { template struct Inner {}; template struct Inner { template void foo() requires C && C && C{} template void foo() requires true{} }; }; void bar() { Outer::Inner I; I.foo(); } } // namespace GH61959 namespace TemplateInsideTemplateInsideTemplate { template concept C1 = false; template struct W0 { template struct W1 { template struct F { enum { value = 1 }; }; template requires C1 struct F { enum { value = 2 }; }; }; }; static_assert(W0<0>::W1<1>::F::value == 1); } // TemplateInsideTemplateInsideTemplate namespace GH63181 { template void f() { auto l = []() requires N { }; // expected-note 2{{candidate function not viable: constraints not satisfied}} \ // expected-note 2{{because 'false' evaluated to false}} l(); // expected-error@-1 {{no matching function for call to object of type}} void(*ptr)() = l; // expected-error-re@-1 {{no viable conversion from '(lambda {{.*}})' to 'void (*)()'}} } template void f(); // expected-note {{in instantiation of function template specialization 'GH63181::f' requested here}} template void f(); template concept C = __is_same(T, int); // expected-note{{because '__is_same(char, int)' evaluated to false}} template void f() { ([]() requires C { return Ts(); }(), ...); // expected-error@-1 {{no matching function for call to object of type}} \ // expected-note@-1 {{candidate function not viable: constraints not satisfied}} \ // expected-note@-1 {{because 'char' does not satisfy 'C'}} } template void f(); template void f(); //expected-note@-1{{in instantiation of function template specialization 'GH63181::f' requested here}} template concept Test = IsTrue; // expected-note 2{{because 'false' evaluated to false}} template void params() { auto l = [](T t) // expected-note 2{{candidate function not viable: constraints not satisfied}} requires Test // expected-note 2{{because 'Test' evaluated to false}} {}; using F = void(T); F* f = l; // expected-error {{no viable conversion from}} l(0); // expected-error {{no matching function for call to object}} } void test_params() { params(); params(); // expected-note {{in instantiation of function template specialization 'GH63181::params' requested here}} } } namespace GH54678 { template concept True = true; template concept False = false; // expected-note 9 {{'false' evaluated to false}} template concept Irrelevant = false; template concept ErrorRequires = requires(ErrorRequires auto x) { x; }; // expected-error {{unknown type name 'ErrorRequires'}} template void aaa(T t) // expected-note {{candidate template ignored: constraints not satisfied}} requires (False || False) || False {} // expected-note 3 {{'int' does not satisfy 'False'}} template void bbb(T t) // expected-note {{candidate template ignored: constraints not satisfied}} requires (False || False) && True {} // expected-note 2 {{'long' does not satisfy 'False'}} template void ccc(T t) // expected-note {{candidate template ignored: constraints not satisfied}} requires (True || Irrelevant) && False {} // expected-note {{'unsigned long' does not satisfy 'False'}} template void ddd(T t) // expected-note {{candidate template ignored: constraints not satisfied}} requires (Irrelevant || True) && False {} // expected-note {{'int' does not satisfy 'False'}} template void eee(T t) // expected-note {{candidate template ignored: constraints not satisfied}} requires (Irrelevant || Irrelevant || True) && False {} // expected-note {{'long' does not satisfy 'False'}} template void fff(T t) // expected-note {{candidate template ignored: constraints not satisfied}} requires((ErrorRequires || False || True) && False) {} // expected-note {{'unsigned long' does not satisfy 'False'}} void test() { aaa(42); // expected-error {{no matching function}} bbb(42L); // expected-error{{no matching function}} ccc(42UL); // expected-error {{no matching function}} ddd(42); // expected-error {{no matching function}} eee(42L); // expected-error {{no matching function}} fff(42UL); // expected-error {{no matching function}} } } namespace GH66612 { template auto end(C c) ->int; template concept Iterator = true; template concept Container = requires(CT b) { { end } -> Iterator; // #66612GH_END }; static_assert(Container);// expected-error{{static assertion failed}} // expected-note@-1{{because 'int' does not satisfy 'Container'}} // expected-note@#66612GH_END{{because 'end' would be invalid: reference to overloaded function could not be resolved; did you mean to call it?}} } namespace GH66938 { template concept True = true; template concept False = false; template void cand(T t) requires False || False || False || False || False || False || False || False || False || True {} void test() { cand(42); } } namespace GH63837 { template concept IsFoo = true; template struct Struct { template void foo() {} template requires (... && IsFoo) void bar() {} template static inline int field = 0; }; template void Struct::foo<>(); template void Struct::bar<>(); template int Struct::field<1, 2>; }