smart pointers

Discussion in 'C++' started by Mohammad, Aug 4, 2004.

  1. Mohammad

    Mohammad Guest

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

    -Thanks
     
    Mohammad, Aug 4, 2004
    #1
    1. Advertising

  2. * 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?
     
    Alf P. Steinbach, Aug 4, 2004
    #2
    1. Advertising

  3. 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
     
    Victor Bazarov, Aug 4, 2004
    #3
  4. "Victor Bazarov" <> wrote in message
    news:BCcQc.465$09.us.to.verio.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
     
    Jonathan Turkanis, Aug 4, 2004
    #4
  5. "Jonathan Turkanis" <> wrote...
    >
    > "Victor Bazarov" <> wrote in message
    > news:BCcQc.465$09.us.to.verio.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
     
    Victor Bazarov, Aug 5, 2004
    #5
  6. "Victor Bazarov" <> wrote in message
    news:hqeQc.245725$Oq2.147653@attbi_s52...
    > "Jonathan Turkanis" <> wrote...
    > >
    > > "Victor Bazarov" <> wrote in message
    > > news:BCcQc.465$09.us.to.verio.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
     
    Jonathan Turkanis, Aug 5, 2004
    #6
  7. Mohammad

    Mohammad Guest

    "Jonathan Turkanis" <> wrote in message news:<>...
    > "Victor Bazarov" <> wrote in message
    > news:hqeQc.245725$Oq2.147653@attbi_s52...
    > > "Jonathan Turkanis" <> wrote...
    > > >
    > > > "Victor Bazarov" <> wrote in message
    > > > news:BCcQc.465$09.us.to.verio.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
     
    Mohammad, Aug 5, 2004
    #7
  8. "Mohammad" <> wrote in message
    news:...
    > "Jonathan Turkanis" <> wrote in message

    news:<>...
    > > "Victor Bazarov" <> wrote in message
    > > news:hqeQc.245725$Oq2.147653@attbi_s52...
    > > > "Jonathan Turkanis" <> wrote...
    > > > >
    > > > > "Victor Bazarov" <> wrote in message
    > > > > news:BCcQc.465$09.us.to.verio.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
     
    John Harrison, Aug 5, 2004
    #8
  9. Mohammad

    Mike Wahler Guest

    "Mohammad" <> wrote in message
    news:...
    > 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
     
    Mike Wahler, Aug 5, 2004
    #9
  10. "Mohammad" <> wrote in message
    news:...

    >
    > 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
     
    Jonathan Turkanis, Aug 6, 2004
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Evan
    Replies:
    1
    Views:
    1,337
    Howard Hinnant
    Jun 23, 2003
  2. Bonzo
    Replies:
    1
    Views:
    428
    Cy Edmunds
    Jul 23, 2003
  3. MotoK
    Replies:
    59
    Views:
    1,922
    Keith Thompson
    Sep 15, 2006
  4. n2xssvv g02gfr12930

    Smart pointers and member function pointers

    n2xssvv g02gfr12930, Nov 26, 2005, in forum: C++
    Replies:
    3
    Views:
    502
    n2xssvv g02gfr12930
    Nov 27, 2005
  5. cerr

    pointers, pointers, pointers...

    cerr, Apr 7, 2011, in forum: C Programming
    Replies:
    12
    Views:
    739
Loading...

Share This Page