<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<div class="moz-text-flowed"
style="font-family: -moz-fixed; font-size: 13px;" lang="x-western">Luis
Ibanez wrote:
<br>
<blockquote type="cite"><snip>
<br>
<br>
3) Please note that the construction
<br>
<br>
const Image::ConstPointer & ptr ....;
<br>
<br>
prevents the internal mechanisms of the SmartPointer
<br>
from working, since the "const" keyword prevents the "ptr"
<br>
variable from changing. (strictly speaking it prevents the
<br>
smart pointer from calling the non-const method Register()
<br>
on the object that it points to).
<br>
</blockquote>
I take back what I said in the reply I just posted a minute ago (when
it comes through on the list) - you don't need to make Register() and
UnRegister() const methods, you just need to add a templated
constructor like this:
<br>
<br>
template <typename T>
<br>
SmartPointer(const SmartPointer<T>& p)
<br>
: m_Pointer(p.GetPointer())
<br>
{ this->Register(); }
<br>
<br>
Not sure if that causes any obvious problems at all though? It should
only compile if p.GetPointer()'s type is convertible to m_Pointer's
type, so I can't see an obvious problem, but there may be other things
lurking that I've missed.
<br>
<br>
Cheers,
<br>
Stu
<br>
<blockquote type="cite"> Regards,
<br>
<br>
<br>
Luis
<br>
<br>
<snip><br>
</blockquote>
</div>
</body>
</html>