I've nested a template in a class message
which usually contains a subclass of message
, but if I want it contain message
itself, I run into problems of conflicting ctor overloads. (It would be good if I could somehow get it to ignore one of the conflicting methods, but I don't know how.) So I try to make a specialization of the messsage
containee, but then I get
explicit specialization in non-namespace scope 'class message'
I've researched how to deal with errors like that (like here, here and here) but I can't figure out how to shoehorn those solutions into my problem.
class message {
template<class T>
class sptrTemplate : public QSharedPointer<T>
{
public:
sptrTemplate() : QSharedPointer<T>() {}
sptrTemplate(T *msg_ptr) : QSharedPointer<T>(msg_ptr) {}
sptrTemplate(message *msg_ptr) : QSharedPointer<T>(static_cast<T *>(msg_ptr)) {}
};
};
Remember, T
is usually a subclass of message
. The only exception is when T
is message
. Then, there's an obvious conflict between the 2nd and 3rd ctor. But if I try specializing with
template <>
class sptrTemplate<message> : public QSharedPointer<message>
{
public:
sptr() : QSharedPointer<message>() {}
sptr(message *msg_ptr) : QSharedPointer<message>(msg_ptr) {}
};
then I get that compiler error, and I can't figure out how to deal with that.