summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/template/mem_func_ptr.C
blob: 7d912e2adbbe67c0a3cb0399f913de1802671746 (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
50
51
52
53
54
55
56
57
// { dg-do compile }
template<typename T> struct takes_member_ptr;
template<typename T, typename Klasse> struct takes_member_ptr<T Klasse::*> {};

template<typename T, typename Klasse>
void fun_takes_member_ptr(T Klasse::*) {}


template<typename T> struct order_member_ptrs;
template<typename T, typename Klasse> struct order_member_ptrs<T Klasse::*> {};
template<typename R, typename T1, typename Klasse> 
  struct order_member_ptrs<R (Klasse::*)(T1)>
  {
    typedef int type;
  };

template<typename R, typename T1, typename Klasse>
  struct order_member_ptrs<R (Klasse::*)(T1) const>
  {
    typedef int c_type;
  };

template<typename R, typename T1, typename Klasse>
  struct order_member_ptrs<R (Klasse::*)(T1) volatile>
  {
    typedef int v_type;
  };

template<typename R, typename T1, typename Klasse>
  struct order_member_ptrs<R (Klasse::*)(T1) const volatile>
  {
    typedef int cv_type;
  };

	  
struct X {
  void bar(float) {}
  void bar_c(float) const {}
  void bar_v(float) volatile {}
  void bar_cv(float) const volatile {}
};

void foo()
{
  sizeof(takes_member_ptr<void (X::*)(float)>);
  sizeof(takes_member_ptr<void (X::*)(float) const>);
  sizeof(takes_member_ptr<void (X::*)(float) volatile>);
  sizeof(takes_member_ptr<void (X::*)(float) const volatile>);
  sizeof(order_member_ptrs<void (X::*)(float)>::type);
  sizeof(order_member_ptrs<void (X::*)(float) const>::c_type);
  sizeof(order_member_ptrs<void (X::*)(float) volatile>::v_type);
  sizeof(order_member_ptrs<void (X::*)(float) const volatile>::cv_type);
  fun_takes_member_ptr(&X::bar);
  fun_takes_member_ptr(&X::bar_c);
  fun_takes_member_ptr(&X::bar_v);
  fun_takes_member_ptr(&X::bar_cv);
}