aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/concepts3.C
blob: 1e28e31ad88a1ca91a68297261f67270d5576c31 (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
// { dg-do compile { target c++20 } }

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

template<typename T>
concept C1 = requires (T& t) { // { dg-message "in requirements" }
  t.~T(); 
};

template<typename T>
concept C2 = requires (T& t) { // { dg-message "in requirements" }
  { t.~T() } -> same_as<void>;
};

template<typename T>
concept C3 = requires { // { dg-message "in requirements" }
  typename T::type;
};

class S1
{
  ~S1() { }
  using type = int;
};

void driver() {
  static_assert(C1<S1>, ""); // { dg-error "static assertion failed" }
  static_assert(C2<S1>, ""); // { dg-error "static assertion failed" }
  static_assert(C3<S1>, ""); // { dg-error "static assertion failed" }
}

template<typename T>
  requires C1<T>
void f1() { }

template<typename T>
  requires C2<T>
void f2() { }

template<typename T>
  requires C3<T>
void f3() { }

void driver2() {
  f1<S1>(); // { dg-error "no match" }
  f2<S1>(); // { dg-error "no match" }
  f3<S1>(); // { dg-error "no match" }
}