comparison gcc/testsuite/g++.dg/concepts/variadic2.C @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 // { dg-do compile { target c++17 } } 1 // { dg-do compile { target c++17_only } }
2 // { dg-options "-fconcepts" } 2 // { dg-options "-fconcepts" }
3 3
4 template <class T> concept bool Copyable = requires (T t) { T(t); }; 4 template <class T> concept bool Copyable = requires (T t) { T(t); };
5 template <class T> concept bool Constructable = requires { T(); }; 5 template <class T> concept bool Constructable = requires { T(); };
6 template <class T> concept bool Both = Copyable<T> && Constructable<T>; 6 template <class T> concept bool Both = Copyable<T> && Constructable<T>;
7 7
8 template <Copyable... Ts> 8 template <Copyable... Ts> // requires (Copyable<Ts> && ...)
9 constexpr int f(Ts...) { return 0; } // #1 9 constexpr int f(Ts...) { return 0; } // #1
10 10
11 template <Both... Ts> 11 template <Both... Ts> // requires (Both<Ts> && ...)
12 constexpr int f(Ts...) { return 1; } // #2 12 constexpr int f(Ts...) { return 1; } // #2
13 13
14 int main() 14 int main()
15 { 15 {
16 static_assert(f(42) == 1); 16 static_assert(f(42) == 1); // { dg-error "ambiguous" }
17 // The associated constraints of the two functions are incomparable.
17 } 18 }