Debian Codegraph @

clang/test/SemaTemplate/cxx2a-constraint-caching.cpp

raw
1 // RUN: %clang_cc1 -std=c++2a -verify %s
2 // expected-no-diagnostics
3
4 template<typename T>
5 concept C = (f(T()), true);
6
7 template<typename T>
8 constexpr bool foo() { return false; }
9
10 template<typename T>
11 requires (f(T()), true)
12 constexpr bool foo() requires (f(T()), true) { return true; }
13
14 namespace a {
15 struct A {};
16 constexpr void f(A a) {}
17 }
18
19 static_assert(C<a::A>);
20 static_assert(foo<a::A>());
21
22 namespace a {
23 // This makes calls to f ambiguous, but the second check will still succeed
24 // because the constraint satisfaction results are cached.
25 constexpr void f(A a, int = 2) {}
26 }
27 static_assert(C<a::A>);
28 static_assert(foo<a::A>());