1// PR c++/52744
2// { dg-do compile { target c++11 } }
3
4struct T
5{
6  int a;
7  void b(){}
8  int c(int)
9  {
10    return 1;
11    }
12};
13
14template<typename CT, CT> struct member_helper;
15
16template<typename FT, FT(T::*mem)>
17struct member_helper<FT(T::*), mem>
18{
19  static const char* worker()
20  {
21    return "for members";
22  }
23};
24
25template<typename Return, typename... Args, Return(T::*fun)(Args...)>
26struct member_helper<Return(T::*)(Args...), fun>
27{
28  static const char* worker()
29  {
30    return "for member functions returning non void";
31  }
32};
33
34template<typename... Args, void(T::*fun)(Args...)>
35struct member_helper<void(T::*)(Args...), fun>
36{
37  static const char* worker()
38  {
39    return "for member functions returning void";
40  }
41};
42
43void member_test()
44{
45  member_helper<decltype(&T::a), &T::a>::worker();
46  member_helper<decltype(&T::b), &T::b>::worker();
47  member_helper<decltype(&T::c), &T::c>::worker();
48}
49
50typedef void lua_State;
51
52template<typename T, T> class function_helper
53{
54  static_assert(sizeof(T) != sizeof(T),
55		"Error: function_helper works with functions (duh)");
56};
57
58template<typename Return, typename... Args, Return(*func)(Args...)>
59struct function_helper<Return(*)(Args...), func>
60{
61  static int wrapper(lua_State* l)
62  {
63    return 1;
64  }
65};
66
67template<typename... Args, void(*func)(Args...)>
68struct function_helper<void(*)(Args...), func>
69{
70  static int wrapper(lua_State* l)
71  {
72    return 0;
73  }
74};
75
76int ciao(int){ return 0; }
77void ciao2(int){}
78
79void function_test()
80{
81  function_helper<decltype(&ciao), &ciao>::wrapper(0);
82  function_helper<decltype(&ciao2), &ciao2>::wrapper(0);
83}
84