T
Tobias Langner
compiling this line:
SmartPtr<LongWrapper, RefCount> p1=SmartPtr<LongWrapper, RefCount>(new
LongWrapper(1));
with SmartPtr being:
template <class T, template <class> class OwnershipPolicy>
class SmartPtr : public OwnershipPolicy<T> {
public:
explicit SmartPtr(T* pointer);
SmartPtr(SmartPtr<T, OwnershipPolicy>& otherPointer);
SmartPtr<T, OwnershipPolicy> &operator=(SmartPtr<T, OwnershipPolicy> &);
SmartPtr<T, OwnershipPolicy> &operator=(T*);
~SmartPtr();
bool isNULL() { return pointer_==NULL; }
T& operator*() const;
T* operator->() const;
private:
void deleteObject();
void copyPtr(SmartPtr<T, OwnershipPolicy>& otherPointer);
void copyPtr(T* otherPointer);
SmartPtr();
T* pointer_;
};
i get the following error:
test.cpp:22: no matching function for call to `SmartPtr<LongWrapper,
RefCount>::SmartPtr(SmartPtr<LongWrapper, RefCount>)' smartptr.h:105:
candidates are: SmartPtr<T, OwnershipPolicy>::SmartPtr(SmartPtr<T,
OwnershipPolicy>&) [with T = LongWrapper, OwnershipPolicy = RefCount]
wich I don't understand.
SmartPtr<LongWrapper, RefCount> p1=SmartPtr<LongWrapper, RefCount>(new
LongWrapper(1));
with SmartPtr being:
template <class T, template <class> class OwnershipPolicy>
class SmartPtr : public OwnershipPolicy<T> {
public:
explicit SmartPtr(T* pointer);
SmartPtr(SmartPtr<T, OwnershipPolicy>& otherPointer);
SmartPtr<T, OwnershipPolicy> &operator=(SmartPtr<T, OwnershipPolicy> &);
SmartPtr<T, OwnershipPolicy> &operator=(T*);
~SmartPtr();
bool isNULL() { return pointer_==NULL; }
T& operator*() const;
T* operator->() const;
private:
void deleteObject();
void copyPtr(SmartPtr<T, OwnershipPolicy>& otherPointer);
void copyPtr(T* otherPointer);
SmartPtr();
T* pointer_;
};
i get the following error:
test.cpp:22: no matching function for call to `SmartPtr<LongWrapper,
RefCount>::SmartPtr(SmartPtr<LongWrapper, RefCount>)' smartptr.h:105:
candidates are: SmartPtr<T, OwnershipPolicy>::SmartPtr(SmartPtr<T,
OwnershipPolicy>&) [with T = LongWrapper, OwnershipPolicy = RefCount]
wich I don't understand.