mangle-template.cpp [plain text]
namespace test1 {
int x;
template <int& D> class T { };
void f0(T<x> a0) {}
}
namespace test1 {
void f0(float) {}
template<void (&)(float)> struct t1 {};
void f1(t1<f0> a0) {}
}
namespace test2 {
void f0(float) {}
template<void (*)(float)> struct t1 {};
void f1(t1<f0> a0) {}
}
namespace test3 {
extern "C" void test3_f0(float) {}
template<void (&)(float)> struct t1 {};
void f1(t1<test3_f0> a0) {}
}
namespace test4 {
extern "C" void test4_f0(float) {}
template<void (*)(float)> struct t1 {};
void f1(t1<test4_f0> a0) {}
}
extern "C" void test5_f0(float) {}
int main(int) {}
namespace test5 {
template<void (&)(float)> struct t1 {};
void f1(t1<test5_f0> a0) {}
template<int (&)(int)> struct t2 {};
void f2(t2<main> a0) {}
}
namespace test6 {
struct A { void im0(float); };
void A::im0(float) {}
template <void(A::*)(float)> class T { };
void f0(T<&A::im0> a0) {}
}
namespace test7 {
template<typename T>
struct meta {
static const unsigned value = sizeof(T);
};
template<unsigned> struct int_c {
typedef float type;
};
template<typename T>
struct X {
template<typename U>
X(U*, typename int_c<(meta<T>::value + meta<U>::value)>::type *) { }
};
template X<int>::X(double*, float*);
}
namespace test8 {
template<typename T>
struct meta {
struct type {
static const unsigned value = sizeof(T);
};
};
template<unsigned> struct int_c {
typedef float type;
};
template<typename T>
void f(int_c<meta<T>::type::value>) { }
template void f<int>(int_c<sizeof(int)>);
}
namespace test9 {
template<typename T>
struct supermeta {
template<typename U>
struct apply {
typedef T U::*type;
};
};
struct X { };
template<typename T, typename U>
typename supermeta<T>::template apply<U>::type f();
void test_f() {
f<int, X>();
}
}
namespace test10 {
template<typename T>
struct X {
template<typename U>
struct definition {
};
};
template<typename T, typename U>
typename X<T>::template definition<U> f(T, U) { }
void g(int i, double d) {
f(i, d);
}
}
namespace test11 {
int cmp(char a, char b);
template <typename T, int (*cmp)(T, T)> struct A {};
template <typename T> void f(A<T,cmp> &) {}
template void f<char>(A<char,cmp> &);
}
namespace test12 {
static int f();
const int n = 10;
template<typename T, T v> void test() {}
void use() {
test<int(), &f>();
test<int(&)(), f>();
test<const int*, &n>();
test<const int&, n>();
}
}
namespace test13 {
template <char c> char returnChar() { return c; }
template char returnChar<-128>();
template <short s> short returnShort() { return s; }
template short returnShort<-32768>();
}