cxx-templates.h revision 0e0363866792b309d70e9c8e92b4c239773af89c
1// Header for PCH test cxx-templates.cpp
2
3template <typename T1, typename T2>
4struct S;
5
6template <typename T1, typename T2>
7struct S {
8  S() { }
9  static void templ();
10};
11
12template <typename T>
13struct S<int, T> {
14    static void partial();
15};
16
17template <>
18struct S<int, float> {
19    static void explicit_special();
20};
21
22template <int x>
23int tmpl_f2() { return x; }
24
25template <typename T, int y>
26T templ_f(T x) {
27  int z = templ_f<int, 5>(3);
28  z = tmpl_f2<y+2>();
29  T data[y];
30  return x+y;
31}
32
33void govl(int);
34void govl(char);
35
36template <typename T>
37struct Unresolv {
38  void f() {
39    govl(T());
40  }
41};
42
43template <typename T>
44struct Dep {
45  typedef typename T::type Ty;
46  void f() {
47    Ty x = Ty();
48    T::my_f();
49    int y = T::template my_templf<int>(0);
50    ovl(y);
51  }
52
53  void ovl(int);
54  void ovl(float);
55};
56
57template<typename T, typename A1>
58inline T make_a(const A1& a1) {
59  T::depend_declref();
60  return T(a1);
61}
62
63template <class T> class UseBase {
64  void foo();
65  typedef int bar;
66};
67
68template <class T> class UseA : public UseBase<T> {
69  using UseBase<T>::foo;
70  using typename UseBase<T>::bar;
71};
72
73template <class T> class Sub : public UseBase<int> { };
74
75template <class _Ret, class _Tp>
76  class mem_fun_t
77  {
78  public:
79    explicit
80    mem_fun_t(_Ret (_Tp::*__pf)())
81     {}
82
83  private:
84    _Ret (_Tp::*_M_f)();
85  };
86
87template<unsigned N>
88bool isInt(int x);
89
90template<> bool isInt<8>(int x) {
91  try { ++x; } catch(...) { --x; }
92  return true;
93}
94
95template<typename _CharT>
96int __copy_streambufs_eof(_CharT);
97
98class basic_streambuf
99{
100  void m() { }
101  friend int __copy_streambufs_eof<>(int);
102};
103
104// PR 7660
105template<typename T> struct S_PR7660 { void g(void (*)(T)); };
106 template<> void S_PR7660<int>::g(void(*)(int)) {}
107
108// PR 7670
109template<typename> class C_PR7670;
110template<> class C_PR7670<int>;
111template<> class C_PR7670<int>;
112
113template <bool B>
114struct S2 {
115    static bool V;
116};
117
118extern template class S2<true>;
119
120template <typename T>
121struct S3 {
122    void m();
123};
124
125template <typename T>
126inline void S3<T>::m() { }
127
128template <typename T>
129struct S4 {
130    void m() { }
131};
132extern template struct S4<int>;
133
134void S4ImplicitInst() {
135    S4<int> s;
136    s.m();
137}
138