Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > smart pointers

Reply
Thread Tools

smart pointers

 
 
Mohammad
Guest
Posts: n/a
 
      08-04-2004
Is there a difference between smart pointers and automatic pointers or
they refer to the same idea.

-Thanks
 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      08-04-2004
* 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?
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      08-04-2004
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
 
Reply With Quote
 
Jonathan Turkanis
Guest
Posts: n/a
 
      08-04-2004

"Victor Bazarov" <(E-Mail Removed)> wrote in message
news:BCcQc.465$(E-Mail Removed)09.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.

Jonathan


 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      08-04-2004
"Jonathan Turkanis" <(E-Mail Removed)> wrote...
>
> "Victor Bazarov" <(E-Mail Removed)> wrote in message
> news:BCcQc.465$(E-Mail Removed)09.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


 
Reply With Quote
 
Jonathan Turkanis
Guest
Posts: n/a
 
      08-05-2004

"Victor Bazarov" <(E-Mail Removed)> wrote in message
news:hqeQc.245725$Oq2.147653@attbi_s52...
> "Jonathan Turkanis" <(E-Mail Removed)> wrote...
> >
> > "Victor Bazarov" <(E-Mail Removed)> wrote in message
> > news:BCcQc.465$(E-Mail Removed)09.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


 
Reply With Quote
 
Mohammad
Guest
Posts: n/a
 
      08-05-2004
"Jonathan Turkanis" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> "Victor Bazarov" <(E-Mail Removed)> wrote in message
> news:hqeQc.245725$Oq2.147653@attbi_s52...
> > "Jonathan Turkanis" <(E-Mail Removed)> wrote...
> > >
> > > "Victor Bazarov" <(E-Mail Removed)> wrote in message
> > > news:BCcQc.465$(E-Mail Removed)09.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
 
Reply With Quote
 
John Harrison
Guest
Posts: n/a
 
      08-05-2004

"Mohammad" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> "Jonathan Turkanis" <(E-Mail Removed)> wrote in message

news:<(E-Mail Removed)>...
> > "Victor Bazarov" <(E-Mail Removed)> wrote in message
> > news:hqeQc.245725$Oq2.147653@attbi_s52...
> > > "Jonathan Turkanis" <(E-Mail Removed)> wrote...
> > > >
> > > > "Victor Bazarov" <(E-Mail Removed)> wrote in message
> > > > news:BCcQc.465$(E-Mail Removed)09.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


 
Reply With Quote
 
Mike Wahler
Guest
Posts: n/a
 
      08-05-2004

"Mohammad" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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


 
Reply With Quote
 
Jonathan Turkanis
Guest
Posts: n/a
 
      08-06-2004

"Mohammad" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pointers, pointers, pointers... cerr C Programming 12 04-07-2011 11:17 PM
Smart Pointers: Is there something similar to smart pointers in C? MotoK C Programming 59 09-15-2006 07:03 PM
Smart pointers and member function pointers n2xssvv g02gfr12930 C++ 3 11-27-2005 10:51 AM
Smart Card Certificate Logon and Smart Card Wireless EAP-TLS erha Wireless Networking 0 05-19-2005 01:40 AM
trade 64mb smart media for 16mb smart media cards wjva Digital Photography 1 08-20-2003 08:30 PM



Advertisments