2010-06-20 03:28:53 +08:00
|
|
|
// Header for PCH test cxx-templates.cpp
|
|
|
|
|
2010-07-02 19:55:48 +08:00
|
|
|
template <typename T1, typename T2>
|
|
|
|
struct S;
|
|
|
|
|
2010-06-23 21:48:30 +08:00
|
|
|
template <typename T1, typename T2>
|
2010-06-20 03:28:53 +08:00
|
|
|
struct S {
|
2010-07-02 19:55:48 +08:00
|
|
|
S() { }
|
2010-06-23 21:48:30 +08:00
|
|
|
static void templ();
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct S<int, T> {
|
|
|
|
static void partial();
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct S<int, float> {
|
|
|
|
static void explicit_special();
|
2010-06-20 03:28:53 +08:00
|
|
|
};
|
2010-06-22 17:55:07 +08:00
|
|
|
|
2010-06-28 17:31:42 +08:00
|
|
|
template <int x>
|
|
|
|
int tmpl_f2() { return x; }
|
|
|
|
|
2010-06-26 00:25:09 +08:00
|
|
|
template <typename T, int y>
|
2010-06-22 17:55:07 +08:00
|
|
|
T templ_f(T x) {
|
2010-06-28 17:31:34 +08:00
|
|
|
int z = templ_f<int, 5>(3);
|
2010-06-28 17:31:42 +08:00
|
|
|
z = tmpl_f2<y+2>();
|
2010-06-30 16:49:25 +08:00
|
|
|
T data[y];
|
2010-06-26 00:25:09 +08:00
|
|
|
return x+y;
|
2010-06-22 17:55:07 +08:00
|
|
|
}
|
2010-06-24 16:57:31 +08:00
|
|
|
|
2010-06-25 17:03:34 +08:00
|
|
|
void govl(int);
|
|
|
|
void govl(char);
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct Unresolv {
|
|
|
|
void f() {
|
|
|
|
govl(T());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-06-24 16:57:31 +08:00
|
|
|
template <typename T>
|
|
|
|
struct Dep {
|
|
|
|
typedef typename T::type Ty;
|
|
|
|
void f() {
|
|
|
|
Ty x = Ty();
|
|
|
|
T::my_f();
|
|
|
|
int y = T::template my_templf<int>(0);
|
2010-06-25 17:03:26 +08:00
|
|
|
ovl(y);
|
2010-06-24 16:57:31 +08:00
|
|
|
}
|
2010-06-25 17:03:26 +08:00
|
|
|
|
|
|
|
void ovl(int);
|
|
|
|
void ovl(float);
|
2010-06-24 16:57:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T, typename A1>
|
|
|
|
inline T make_a(const A1& a1) {
|
2010-06-28 17:31:56 +08:00
|
|
|
T::depend_declref();
|
2010-06-24 16:57:31 +08:00
|
|
|
return T(a1);
|
|
|
|
}
|
2010-06-30 16:49:30 +08:00
|
|
|
|
|
|
|
template <class T> class UseBase {
|
|
|
|
void foo();
|
|
|
|
typedef int bar;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class T> class UseA : public UseBase<T> {
|
|
|
|
using UseBase<T>::foo;
|
|
|
|
using typename UseBase<T>::bar;
|
|
|
|
};
|
2010-07-02 19:55:48 +08:00
|
|
|
|
|
|
|
template <class T> class Sub : public UseBase<int> { };
|
|
|
|
|
|
|
|
template <class _Ret, class _Tp>
|
|
|
|
class mem_fun_t
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit
|
|
|
|
mem_fun_t(_Ret (_Tp::*__pf)())
|
|
|
|
{}
|
|
|
|
|
|
|
|
private:
|
|
|
|
_Ret (_Tp::*_M_f)();
|
|
|
|
};
|
|
|
|
|
|
|
|
template<unsigned N>
|
|
|
|
bool isInt(int x);
|
|
|
|
|
|
|
|
template<> bool isInt<8>(int x) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename _CharT>
|
|
|
|
int __copy_streambufs_eof(_CharT);
|
|
|
|
|
|
|
|
class basic_streambuf
|
|
|
|
{
|
|
|
|
void m() { }
|
|
|
|
friend int __copy_streambufs_eof<>(int);
|
|
|
|
};
|
|
|
|
|