Partial specialization
Stefan Meixner (none)
stefan@emskopp.a.shuttle.de
Tue Sep 2 08:34:00 GMT 1997
While testing the 970828 egcs snapshot I ran across
a 'bug' with the partial template specialization
implementation. I was testing g++ with the Blitz++
library, testing for the partial specialization
ability of g++. g++ is not able to compile
the following code example
-----------------------------------------------------------
// Partial specialization
template<class T_type, int N>
class foo {
public:
enum bar { z = 0 };
};
template<int N>
class foo<double, N> {
public:
enum bar { z = 1 };
};
template<class T_type>
class foo<T_type, 2> {
public:
enum bar { z = 2 };
};
int main()
{
if ((foo<int,3>::z == 0) && (foo<double,3>::z == 1)
&& (foo<float,2>::z == 2))
return 0;
else
return 1;
}
-----------------------------------------------------------
g++ -c partial.cpp
partial.cpp: In function `int main()':
partial.cpp:25: ambiguous class template instantiation for `class foo<float,2>'
partial.cpp:20: candidates are: class foo<T_type,2>
partial.cpp:14: class foo<double,N>
partial.cpp:25: incomplete type `foo<float,2>' does not have member `z
Changing float into char everything is working as expected.
Stefan
More information about the Gcc
mailing list