Andriy R
2008-05-07 11:15:07 UTC
Hello
Could someone explain the reason of the next compile error?
CodeGear™ C++Builder® 2007 R2 Version 11.0.2987.10779
//header-file
template <typename T>
class TestC
{
public:
void f();
};
// in cpp file
// explicit instantiation
template class TestC<double>;
// generic impl
template <typename T>
void TestC<T>::f()
{
}
// complete specialization
template <>
void TestC<double>::f()
{}
[BCC32 Error] : E2392 Template instance 'TestC<double>::f()' is already instantiated
Is this a standard rule of templates compiling?
Workaround:
1. move "template class TestC<double>;" clause in the end of cpp-file
2. change order of member function f() impl >> generic after concrete
But all cases leads to another linking error (see Part 1)
Could someone explain the reason of the next compile error?
CodeGear™ C++Builder® 2007 R2 Version 11.0.2987.10779
//header-file
template <typename T>
class TestC
{
public:
void f();
};
// in cpp file
// explicit instantiation
template class TestC<double>;
// generic impl
template <typename T>
void TestC<T>::f()
{
}
// complete specialization
template <>
void TestC<double>::f()
{}
[BCC32 Error] : E2392 Template instance 'TestC<double>::f()' is already instantiated
Is this a standard rule of templates compiling?
Workaround:
1. move "template class TestC<double>;" clause in the end of cpp-file
2. change order of member function f() impl >> generic after concrete
But all cases leads to another linking error (see Part 1)