Adi
comstl::interface_ptr<> is obsolete. It offers nothing that
stlsoft::ref_ptr<> does not; it actually offers less.
I don't know why this component has continued to be available. I've just
grepped all my sources and can find only a single use of it (which I've just
changed).
My apologies for having left it in there.
The preferred approach is to use stlsoft::ref_ptr<>. Why? Because it
facilitates forward declaration of a smart pointer specialisation. (I'm
working on a small article to explain how/why, which I hope to publish -
perhaps on CodeProject - soonish.)
I'm changing comstl/smartptr/interface_ptr.hpp as we speak to issue a
warning if included, and will redefine the class to be implemented in terms
of stlsoft::ref_ptr<>.
Sorry about that ... :$
Matthew
And now to the next question ...

<!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 dir="ltr" bgcolor="#ffffff" text="#000066">
<p style="margin-bottom: 0cm; margin-top: 0pt;"><font size="-1"><font
face="Verdana">I wasn't even aware of ref_ptr.</font></font></p>
<p style="margin-bottom: 0cm; margin-top: 0pt;"><span
style="font-size: 13px;"><font face="Verdana">I'll try it and let you
know how it goes.<br>
</font></span><span style="font-size: 13px;"></span></p>
<p style="margin-bottom: 0cm; margin-top: 0pt;"><span
style="font-size: 13px;"><font face="Verdana">Adi</font></span><br>
</p>
<p style="margin-bottom: 0cm; margin-top: 0pt;"><span
style="font-size: 13px;"></span><br>
</p>
<p style="margin-bottom: 0cm; margin-top: 0pt;"><span
style="font-size: 13px;"></span></p>
<p style="margin-bottom: 0cm; margin-top: 0pt;"><br>
Matthew wrote:<br>
</p>
<blockquote cite="midekrbio$313n$1 digitaldaemon.com" type="cite">
<pre wrap="">Adi
comstl::interface_ptr&lt;&gt; is obsolete. It offers nothing that
stlsoft::ref_ptr&lt;&gt; does not; it actually offers less.
I don't know why this component has continued to be available. I've just
grepped all my sources and can find only a single use of it (which I've just
changed).
My apologies for having left it in there.
The preferred approach is to use stlsoft::ref_ptr&lt;&gt;. Why? Because it
facilitates forward declaration of a smart pointer specialisation. (I'm
working on a small article to explain how/why, which I hope to publish -
perhaps on CodeProject - soonish.)
I'm changing comstl/smartptr/interface_ptr.hpp as we speak to issue a
warning if included, and will redefine the class to be implemented in terms
of stlsoft::ref_ptr&lt;&gt;.
Sorry about that ... :$
Matthew
And now to the next question ...
</pre>
</blockquote>
</body>
</html>

Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
You use conversion constructor and copy assignment, as in:
interface_ptr<IBaseFilter> pSource; // The interface_ptr<> object
{
IBaseFilter* ppSource=3D NULL; // temporary bare pointer
=
if(FAILED(pGraph->AddSourceFilter(a2w(c_str_ptr(filename)),0,&ppSource)))=
{
//...
return 0;
}
pSource =3D interface_ptr<IBaseFilter>(ppSource, false); // =
setting the smart pointer.
}=20
But since, in your code, you've not used a typedef (I would usually =
define IBaseFilter_ptr) this looks like more of a burden than I'm used =
to.
There's no reason why you should do the typedef thing, of course.
btw, I would normally do this differently, as in:
{
IBaseFilter* ppSource=3D NULL; // temporary bare pointer
=
if(FAILED(pGraph->AddSourceFilter(a2w(c_str_ptr(filename)),0,&ppSource)))=
{
//...
return 0;
}
else
{
interface_ptr<IBaseFilter> pSource(ppSource, false); // =
setting the smart pointer.
. . .
}
}=20
But again, there's no reason why you _must_ follow the way I do it. So =
it looks like a set() method's called for. (As you'll probably have =
picked up on by now, I don't like adding _any_ functionality until it's =
proven to be needed. But, once it's proven, well ...)
I'll make this change now, and it'll be in beta 31 (31!). That should be =
available in the next 36 hrs, maybe sooner. ;-)
Cheers
Matthew
"Adi Shavit" <adish gentech.co.il> wrote in message =
news:4575C6FD.9060408 gentech.co.il...
I see that ref_ptr doesn't have a set() method.
How can I implement the code I posted before:
// Create a source filter specified by filename
interface_ptr<IBaseFilter> pSource; // The interface_ptr<> =
object
{
IBaseFilter* ppSource=3D NULL; // temporary bare pointer
=
if(FAILED(pGraph->AddSourceFilter(a2w(c_str_ptr(filename)),0,&ppSource)))=
{
//...
return 0;
}
pSource.set(ppSource, false); // setting the smart pointer.
}=20
Am I missing something??
Adi
Adi Shavit wrote:=20
I wasn't even aware of ref_ptr.
I'll try it and let you know how it goes.
Adi
Matthew wrote:
Adi
comstl::interface_ptr<> is obsolete. It offers nothing that
stlsoft::ref_ptr<> does not; it actually offers less.
I don't know why this component has continued to be available. I've just
grepped all my sources and can find only a single use of it (which I've =
just
changed).
My apologies for having left it in there.
The preferred approach is to use stlsoft::ref_ptr<>. Why? Because it
facilitates forward declaration of a smart pointer specialisation. (I'm
working on a small article to explain how/why, which I hope to publish -
perhaps on CodeProject - soonish.)
I'm changing comstl/smartptr/interface_ptr.hpp as we speak to issue a
warning if included, and will redefine the class to be implemented in =
terms
of stlsoft::ref_ptr<>.
Sorry about that ... :$
Matthew
And now to the next question ...