Consider the following example:
class _ref
{
public:
_ref() {}
_ref(const _ref& that) {}
virtual ~_ref() = 0;
};
_ref::~_ref() {}
template <typename T>
class ref : public _ref
{
protected:
ref(const _ref& that) {}
public:
ref() {}
ref(const ref<T>& that) {}
virtual ~ref() {}
template <typename U>
ref<U> tryCast()
{
bool valid;
if (valid)
return ref<U>(*this);
else
return ref<U>();
}
};
I would like all types of 'ref' objects to have access to each other's protected constructors. Is there any way to do this?
source
share