smart pointers

M

Mohammad

Is there a difference between smart pointers and automatic pointers or
they refer to the same idea.

-Thanks
 
A

Alf P. Steinbach

* Mohammad:
Is there a difference between smart pointers and automatic pointers or
they refer to the same idea.

Can you give an example of what you mean by 'automatic pointer'?
 
V

Victor Bazarov

Alf said:
* Mohammad:



Can you give an example of what you mean by 'automatic pointer'?

Just a guess here: the standard template class is called auto_ptr,
perhaps that's where the "automatic" comes from...

V
 
J

Jonathan Turkanis

Victor Bazarov said:
Just a guess here: the standard template class is called auto_ptr,
perhaps that's where the "automatic" comes from...

I'd guess it means a pointer which deletes the managed pointer when it
is destroyed, with no sharing or transfer of ownership allowed -- like
boost::scoped_ptr. Just a guess.

Jonathan
 
V

Victor Bazarov

Jonathan Turkanis said:
I'd guess it means a pointer which deletes the managed pointer when it
is destroyed, with no sharing or transfer of ownership allowed -- like
boost::scoped_ptr. Just a guess.

Actually, the transfer of ownership does occur in the copy-c-tor, IIRC.
That's how it can be returned from a function.

Victor
 
J

Jonathan Turkanis

Victor Bazarov said:
Actually, the transfer of ownership does occur in the copy-c-tor, IIRC.
That's how it can be returned from a function.

Your talking about auto_ptr, right? I was talking about
boost::scoped_ptr, which is non-copyable.

Jonathan
 
M

Mohammad

Jonathan Turkanis said:
Your talking about auto_ptr, right? I was talking about
boost::scoped_ptr, which is non-copyable.

Jonathan

My impression has been the auto_ptr is the standard library
implementation of the smart pointer concept. com_ptr_t and ComPtr are
more sophisticated ATL implementations. During a conversation with
some one who I think has more experience with C++ than I have, he used
the term 'automatic pointer' which I thought is the same as 'smart
pointer.' So I was just trying to know if I'm correct or not.

Thanks
 
J

John Harrison

Mohammad said:
"Jonathan Turkanis" <[email protected]> wrote in message

My impression has been the auto_ptr is the standard library
implementation of the smart pointer concept. com_ptr_t and ComPtr are
more sophisticated ATL implementations. During a conversation with
some one who I think has more experience with C++ than I have, he used
the term 'automatic pointer' which I thought is the same as 'smart
pointer.' So I was just trying to know if I'm correct or not.

Thanks

Smart pointer means a pointer like class, auto_ptr and com_ptr_t and
boost::shared_ptr are all examples of smart pointers. But different smart
pointers do different things. It is not the case that com_ptr is more
sophisticated than auto_ptr, just that they are different kinds of smart
pointer.

I've never heard the term automatic pointer, so I can't say what your friend
meant by it, perhaps he just made a mistake.

john
 
M

Mike Wahler

Mohammad said:
Is there a difference between smart pointers and automatic pointers or
they refer to the same idea.

I'm not sure what you mean by 'automatic pointer'. A pointer
type with 'auto' storage class would be 'automatic' (in that it
is destroyed automatically when its scope is exited). This has
nothing to do with 'smart pointers'.

If you mean 'std::auto_ptr<>' from the standard library, it is
one of many possible implementations of the general concept 'smart
pointer'.

-Mike
 
J

Jonathan Turkanis

My impression has been the auto_ptr is the standard library
implementation of the smart pointer concept.

For the time being, yes, unfortunately.
com_ptr_t and ComPtr are
more sophisticated ATL implementations. During a conversation with
some one who I think has more experience with C++ than I have, he used
the term 'automatic pointer' which I thought is the same as 'smart
pointer.' So I was just trying to know if I'm correct or not.

All my comments were just trying to guess what you might mean.

Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top