By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,413 Members | 999 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,413 IT Pros & Developers. It's quick & easy.

smart pointers

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

-Thanks
Jul 22 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
* 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'?

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #2

P: n/a
Alf P. Steinbach wrote:
* 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'?


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

V
Jul 22 '05 #3

P: n/a

"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:BC**************@newsread1.dllstx09.us.to.ver io.net...
Alf P. Steinbach wrote:
* Mohammad:
Is there a difference between smart pointers and automatic pointers orthey refer to the same idea.

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...


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
Jul 22 '05 #4

P: n/a
"Jonathan Turkanis" <te******@kangaroologic.com> wrote...

"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:BC**************@newsread1.dllstx09.us.to.ver io.net...
Alf P. Steinbach wrote:
* 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'?


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.


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

Victor
Jul 22 '05 #5

P: n/a

"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:hqeQc.245725$Oq2.147653@attbi_s52...
"Jonathan Turkanis" <te******@kangaroologic.com> wrote...

"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:BC**************@newsread1.dllstx09.us.to.ver io.net...
Alf P. Steinbach wrote: > 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...
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.


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

Jonathan
Jul 22 '05 #6

P: n/a
"Jonathan Turkanis" <te******@kangaroologic.com> wrote in message news:<2n************@uni-berlin.de>...
"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:hqeQc.245725$Oq2.147653@attbi_s52...
"Jonathan Turkanis" <te******@kangaroologic.com> wrote...

"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:BC**************@newsread1.dllstx09.us.to.ver io.net...
> Alf P. Steinbach wrote: > 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...

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.


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
Jul 22 '05 #7

P: n/a

"Mohammad" <mj*******@hotmail.com> wrote in message
news:3d**************************@posting.google.c om...
"Jonathan Turkanis" <te******@kangaroologic.com> wrote in message

news:<2n************@uni-berlin.de>...
"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:hqeQc.245725$Oq2.147653@attbi_s52...
"Jonathan Turkanis" <te******@kangaroologic.com> wrote...
>
> "Victor Bazarov" <v.********@comAcast.net> wrote in message
> news:BC**************@newsread1.dllstx09.us.to.ver io.net...
> > Alf P. Steinbach wrote:

> > > 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...
>
> 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.


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


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
Jul 22 '05 #8

P: n/a

"Mohammad" <mj*******@hotmail.com> wrote in message
news:3d**************************@posting.google.c om...
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
Jul 22 '05 #9

P: n/a

"Mohammad" <mj*******@hotmail.com> wrote in message
news:3d**************************@posting.google.c om...

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
Jul 22 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.