This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
GCC 2.95.2, Next 3.3; Reference causes error in pickingspecialization
- To: gcc-bugs at gcc dot gnu dot org
- Subject: GCC 2.95.2, Next 3.3; Reference causes error in pickingspecialization
- From: James McKelvey <mckelvey at fafnir dot com>
- Date: Sun, 23 Jan 2000 12:18:54 -0800
- Reply-To: mckelvey at fafnir dot com
GCC 2.95.2
Next Cube running NextSTEP 4.2, 3.3 Developer
Enclosed program demonstrates that when an explicit specialization uses pass
by reference, the non-specialized template is picked:
g++ -o x x.cc
#include <iostream>
class A
{
public:
template <class T>
A(T x);
};
template <class T>
A::
A(T)
{
cout << "T constructor" << endl;
}
template <>
A::
A(int&) /* A(int) */
{
cout << "int constructor" << endl;
}
int main(void)
{
int i = 1;
A b(i);
return 0;
}
Prints "T constructor". If the & is removed, it prints "int constructor".
---
Where diesel guitars from faraway bars, blast out the
best songs from our holy wars. Coyote carnival catches
on fire, all the cops in the world pick us up on radar.
Jim McKelvey mckelvey@fafnir.com