Hard Light Productions Forums
Off-Topic Discussion => Programming => Topic started by: blackhole on January 20, 2009, 04:18:24 am
-
struct QA_DLLEXPORT cAnimEquation : cHolder<cAnimScript>, public cFileIO
{
public:
cAnimEquation(const cAnimEquation& copy);
cAnimEquation(QAnim::cAnimScript *script=0);
cAnimEquation(cAnimScript* script, const cAnimTerm* terms);
~cAnimEquation();
template<class T>
T ResolveT() const;
template<>
double cAnimEquation::ResolveT<double>() const
{
return COP(cAnimScript)->EqResolve<double>(_terms);
}
Produces
error C2908: explicit specialization; 'T QAnim::cAnimEquation::ResolveT<double>(void)' has already been instantiated d:\erik's documents\visual studio 2008\projects\qasm\qanim\canimequation.cpp 40
error C2910: 'QAnim::cAnimEquation::ResolveT' : cannot be explicitly specialized d:\erik's documents\visual studio 2008\projects\qasm\qanim\canimequation.cpp 36
What the ****ing ****.
I have checked the stupid syntax for explicit specialization a bajillion times, i've taken the const off the function, i've made the function return void and instead have a paramater, all to no avail. What in the holy sh!ttacos of hell is going on here?!
EDIT: Found workaround to avoid explicit specialization, but this still weirds me out.
-
Im not an expert with templates, but after looking at http://msdn.microsoft.com/en-us/library/0w9xyawz(VS.80).aspx , I wonder if some include is there, that shouldnt be..?
Basically, the compiler already generated the code for type <int> when he got to the lines you posted, so, well, its an error. Or am I misunderstanding your problem? :>
-
Basically, the compiler already generated the code for type <int> when he got to the lines you posted, so, well, its an error. Or am I misunderstanding your problem? :>
That is exactly why it is impossible. If I remove the template code there, I will get a link error because the code hasn't been generated. If I include the template code, it says its already been generated.
-
I am getting the same kind of error - can you post what your workaround is? Thanks!
-
I did this:
struct cAnimEquation
{
template<class T>
T ResolveT() const;
};
template<class T>
T cAnimEquation::ResolveT() const
{
return 0.0;
}
template<>
double cAnimEquation::ResolveT<double>() const
{
return 0.0;
}
int main()
{
return 0;
}
Worked fine.
Also tried:
struct cHolder
{
template<class T>
T ResolveT() const;
};
template<class T>
T cHolder::ResolveT() const
{
return 0.0;
}
template<>
double cHolder::ResolveT<double>() const
{
return 0.0;
}
struct cAnimEquation : public cHolder
{
template<class T>
T ResolveT() const;
};
template<class T>
T cAnimEquation::ResolveT() const
{
return 0.0;
}
template<>
double cAnimEquation::ResolveT<double>() const
{
return 0.0;
}
int main()
{
return 0;
}
and it still worked fine.
What happens if you comment out
return COP(cAnimScript)->EqResolve<double>(_terms);
and replace it with a constant?
-
I am getting the same kind of error - can you post what your workaround is? Thanks!
My workaround is program specific and unlikely to be of much help.
If I comment out that line nothing happens.