aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/concepts-fn3.C
blob: e73ae23881aee9bccbaf406be88360650414bef1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// { dg-do compile { target c++2a } }

template<typename T>
concept type = true;

template<typename T, typename U>
concept same_as = __is_same_as(T, U);

template<typename T>
concept integral = __is_same_as(T, int);

template<typename... Ts>
concept all_integral = (integral<Ts> && ...);

void f1(integral auto... args) { }
void f2(all_integral auto... args) { }

template<type T> requires true
void f3(T, integral auto... args) { }

template<type T>
struct S
{
  void f1(integral auto... args) { }
  void f2(all_integral auto... args) { }

  template<type U> requires true
  void f3(U, integral auto... args) { }
};

int main()
{
  f1(1, 2, 3);
  f1(1, 2, 3u); // { dg-error "cannot call" }
  f2(1, 2, 3);
  f2(1, 2, 3u); // { dg-error "cannot call" }
  f3(1, 2, 3);
  f3(1, 2, 3u); // { dg-error "cannot call" }
  f3(1u, 2, 3);

  S<void> s;
  s.f1(1, 2, 3);
  s.f1(1, 2, 3u); // { dg-error "no matching function" }
  s.f2(1, 2, 3);
  s.f2(1, 2, 3u); // { dg-error "no matching function" }
  s.f3(1, 2, 3);
  s.f3(1, 2, 3u); // { dg-error "no matching function" }
  s.f3(1u, 2, 3);
}