Hi,
I have a class with a templatized member function:
class Serializer
{
// ...
template <class T> void serialize(const T& value);
};
Now, I want to specialize for a particular type. It seems that there are a few ways to do this (maybe this is wrong?). One is to create a regular overload like so:
void serialize(const SerializableObject*& value);
Supposedly this will get preference when matching over specific template instantiations but it doesn't seem to be the case (it results in a non-existant template instatiation for SerializableObject* to be created anyway and since I don't have an explicit instantiation for that, it results in unresolved linker errors).
So, I thought I would go with the explicit instantiation approach. Now, perhaps I am getting syntax wrong here but when I put this line in the header file with the class declaration, I get an internal compiler error in VC7.1:
template<> void serialize<SerializableObject*>(const SerializableObject*& value);
produces
fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 2701)
Without declaring in the header, I don't think I can do any explicity instantiation in the C++ file either.
Am I doing something wrong or is this a bug in VC (and is there a workaround if it is)?
Thanks,
Ravi Chodavarapu
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.