This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
specialize a template function out of its namespace
- From: "Yunior Peralta González" <yperaltag at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 3 Jun 2008 00:26:41 -0500
- Subject: specialize a template function out of its namespace
Hi all.
I have the following problem:
namespace test
{
class A
{
template <typename T>
void foo(T &);
};
}
//specialize the function out of namespace test
template <> test::A::foo<int>(int & a)
{
//do something with a
}
if on the contrary I put it this way:
namespace test
{
class A
{
template <typename T>
void foo(T &);
};
//specialize the function inside namespace test
template <> A::foo<int> (int & a)
{
//do something with a
}
}
it works ok.
How can I use the first form without errors?
Thanks in advance.