From 3943539341762976171
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,df06663c0326d841,start
X-Google-Attributes: gidf78e5,public
X-Google-Thread: 109fba,df06663c0326d841,start
X-Google-Attributes: gid109fba,public
From: sjm@cae.co.uk
Subject: auto_ptr copy semantics
Date: 1999/04/10
Message-ID: <7el5br$kjj$1@nnrp1.dejanews.com>#1/1
X-Deja-AN: 464691777
Approved: Valentin Bonnard <bonnard@clipper.ens.fr>
X-Original-Date: Fri, 09 Apr 1999 15:12:02 GMT
X-Authentication-Warning: backdraft.philabs.research.philips.com: smap set sender to <news@dejanews.com> using -f
X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)
X-Http-Proxy: 1.1 x11.dejanews.com:80 (Squid/1.1.22) for client 194.72.41.150
Organization: Deja News - The Leader in Internet Discussion
X-Article-Creation-Date: Fri Apr 09 15:12:02 1999 GMT
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUANw7bBKwEuYhIxRhxAQEEJwIAmzwtLRHlj9klJxREyU3pc2RfWzX5Opeo 5D8ZR4/S65Yl5p67SoFth3VZwKVjdvfZcIhrH+0C5WT3k/0f7PbaTw== =KtbF
Newsgroups: comp.lang.c++,comp.std.c++

What is the rationale behind the copy semantics of auto_ptr
transfering ownership of its contained pointer?

If the auto_ptr is passed to a function by *value*, then isn't
your referenced object extinct upon return (because of local
copies being made which claim ownership and then release the
contained object upon their own demise)?

e.g.

    auto_ptr<Thing> ptr( new Thing );
    doStuff( ptr ); // ...by value.
    // here, ptr no longer refers to anything.

Wouldn't it be better for the *original* auto_ptr to *always*
retain ownership, and for copies to *never* do so?



-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



