PR c++/86728 - C variadic generic lambda.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp0x / variadic-crash1.C
blob211ede611019191ff54eccd99643b6970f767ff9
1 // { dg-do compile { target c++11 } }
3 #define ONE
4 #define TWO
5 #define THREE
7 struct Something {};
8 Something ___;
10 template <class F>
11 struct Trial
13  F f;
14 public:
15  Trial() : f() {}
16  Trial( const F& ff ) : f(ff) { }
17  template <typename... Args>
18  struct Sig { typedef int ResultType; };
20  template <typename... Args>
21  struct Sig<Something,Args...> { typedef int ResultType;  };
23 #ifdef ONE
25 template <typename... Args>
26 typename Sig<Something,Args...>::ResultType operator()(const Something& s, const Args&... args) const
28  return f(args...);
30 #endif
31 #ifdef TWO
32 template <typename... Args>
33 typename Sig<Args...>::ResultType operator()(const Args&... args) const
35  return f(args...);
37 #endif
40 struct Internal
43 template <typename... Args>
44 struct Sig { typedef int ResultType; };
46 template <typename... Args>
47 struct Sig<Something,Args...> { typedef int ResultType;  };
49 template <typename... Args>
50 int operator()(const Args&... args) const
52  int n = sizeof...(Args);
53  return n;
56  static Trial<Internal>& full() { static Trial<Internal> f; return f; }
59 static Trial<Internal>& internal = Internal::full();
61 int main()
63  int n = 0;
64 #ifdef ONE
65  n = internal(___,1,2);
66 #endif
67 #ifdef THREE
68  n = internal(___,1,2,3);
69  n = internal(___,1,2,3,4);
70 #endif
71  return 0;