summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/concepts/fn9.C
blob: c135bd7010a6ca13a4153dc5d17ea1fd140b5a09 (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
// { dg-do run }
// { dg-options "-std=c++1z -fconcepts" }

#include <cassert>

template<typename T>
  concept bool Class() { return __is_class(T); }

template<typename T>
  concept bool Empty() { return Class<T>() and __is_empty(T); }

template<Class T> int f(T) { return 1; }
template<Empty T> int f(T) { return 2; }

struct S {
  template<Class T> int f(T) { return 1; }
  template<Empty T> int f(T) { return 2; }
} s;

struct X { } x;
struct Y { X x; } y;

int main () {
  auto p1 = &f<X>; // Empty f
  assert(p1(x) == 2);

  auto p2 = &f<Y>; // Class f
  assert(p2(y) == 1);

  auto p3 = &S::template f<X>; // Empty f
  assert((s.*p3)(x) == 2);

  auto p4 = &S::template f<Y>; // Empty f
  assert((s.*p4)(y) == 1);
}