Debian Codegraph @

gcc/testsuite/g++.dg/concepts/variadic2.C

raw
1 // { dg-do compile { target c++17 } }
2 // { dg-options "-fconcepts" }
3
4 template <class T> concept Copyable = requires (T t) { T(t); };
5 template <class T> concept Constructable = requires { T(); };
6 template <class T> concept Both = Copyable<T> && Constructable<T>;
7
8 template <Copyable... Ts> // requires (Copyable<Ts> && ...)
9 constexpr int f(Ts...) { return 0; } // #1
10
11 template <Both... Ts> // requires (Both<Ts> && ...)
12 constexpr int f(Ts...) { return 1; } // #2
13
14 int main()
15 {
16 static_assert(f(42) == 1); // { dg-error "ambiguous" }
17 // The associated constraints of the two functions are incomparable.
18 }