Commit fca48256 by Jason Merrill

new

From-SVN: r17530
parent fb0390de
...@@ -4,4 +4,4 @@ template <class T> ...@@ -4,4 +4,4 @@ template <class T>
T foo(T t); T foo(T t);
template <> template <>
int foo<char>(char c); // ERROR - bad return type. int foo<char>(char c); // ERROR - does not match any template declaration
// Build don't link: // Build don't link:
// GROUPS passed templates // GROUPS passed templates
template <class T, class U> template <class T, class U>
T foo(T t, U* u); T foo(T t, U* u); // ERROR - template candidate
template <class T> template <class T>
T foo(T t, T* t); T foo(T t, T* t); // ERROR - template candidate
template <> template <>
int foo<int>(int, int*); // ERROR - ambiguous specialization. int foo<int>(int, int*); // ERROR - ambiguous template specialization
...@@ -3,15 +3,19 @@ extern "C" void abort(); ...@@ -3,15 +3,19 @@ extern "C" void abort();
template <class T> template <class T>
void f(T) void f(T)
{ {
int j;
j = 6;
struct S { struct S {
int i; int i;
}; };
S s; S s;
s.i = 3; s.i = j;
if (s.i != 3) if (s.i != 6)
abort(); abort();
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
struct S struct S
{ {
template <class T> template <class T>
void foo(T); void foo(T) {}
}; };
template void S::foo(int); template void S::foo(int);
......
// Build don't link:
template <class T>
struct S1 {};
template <class T>
void f(T);
template <class C>
struct S2
{
template <class T>
void f<S1<T> >(T) {} // ERROR - bad specialization.
};
template <class T>
struct S3
{
friend class S2<T>;
};
extern "C" void abort();
template <class T>
struct S
{
template <class U>
int f(U u);
};
template <class T>
template <>
int S<T>::f<int>(int i) { return 1; }
int main()
{
S<char> sc;
if (sc.f(3) != 1)
abort();
}
template <class T>
void f(T t);
template <class T>
void f(T* t);
template <>
void f(int* ip) {}
struct S1
{
template <class T>
void f(T t);
template <class T>
void f(T* t);
template <>
void f(int* ip) {}
};
template <class U>
struct S2
{
template <class T>
void f(T t);
template <class T>
void f(T* t);
template <>
void f(int* ip) {}
};
int main()
{
int* ip;
S1 s1;
s1.f(ip);
S2<double> s2;
s2.f(ip);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment