Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #67046
| From | Soviet_Mario <SovietMario@CCCP.MIR> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | [niubbo] aggregate types built in a function and returned by value (on stack). Shallow or Deep copy ? |
| Date | 2019-07-16 00:00 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <qgit2g$qd3$1@dont-email.me> (permalink) |
I've been a long time far from C++ and I realize I have forgotten most, and moreover don't understand "modern" C++ .... anyway When in a function (member or not is irrelevant) I build an aggregate object (class / struct, possibly nested with other), and this aggregate has a DEFAULT public constructor which does not resort to new or new [], but then the said former function invokes some class methods that DO some dynamic allocation, and then the function returns passing outside a copy by-value of the built object to the caller, placed "partially" on the stack, the final copy will be shallow or deep ? With shallow I mean : every automatic member not requiring new or new [], with deep copy I mean exact copy (or even the temporary itself ...). another maybe relevant detail is it relevant whether the COPY constructor is defined or the default one ? How behaves a default generated copy constructor ? Does it perform also new/ new [] operations ? Is it really the COPY constructor that is called on such a situation (returning a complex type by-value instead of by-pointer) ? or a COPY constructor is given, which does not do deep copy, but just "automatic" data is replicated. In case I defined a COPY constructor making dynamic allocation, is it : 1) required, 2) optional or 3) deprecated and possibly dangerous define also an explicit DESTRUCTOR making cleanups ? TY -- 1) Resistere, resistere, resistere. 2) Se tutti pagano le tasse, le tasse le pagano tutti Soviet_Mario - (aka Gatto_Vizzato)
Back to comp.lang.c++ | Previous | Next — Next in thread | Find similar | Unroll thread
[niubbo] aggregate types built in a function and returned by value (on stack). Shallow or Deep copy ? Soviet_Mario <SovietMario@CCCP.MIR> - 2019-07-16 00:00 +0200
Re: [niubbo] aggregate types built in a function and returned by value (on stack). Shallow or Deep copy ? Öö Tiib <ootiib@hot.ee> - 2019-07-15 15:40 -0700
Re: [niubbo] aggregate types built in a function and returned by value (on stack). Shallow or Deep copy ? Soviet_Mario <SovietMario@CCCP.MIR> - 2019-07-16 01:18 +0200
Re: [niubbo] aggregate types built in a function and returned by value (on stack). Shallow or Deep copy ? James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-07-15 21:12 -0400
Re: [niubbo] aggregate types built in a function and returned by value (on stack). Shallow or Deep copy ? Soviet_Mario <SovietMario@CCCP.MIR> - 2019-07-16 14:28 +0200
Re: [niubbo] aggregate types built in a function and returned by value (on stack). Shallow or Deep copy ? James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-07-16 09:47 -0400
Re: [niubbo] aggregate types built in a function and returned by value (on stack). Shallow or Deep copy ? Soviet_Mario <SovietMario@CCCP.MIR> - 2019-07-16 17:16 +0200
Re: [niubbo] aggregate types built in a function and returned by value (on stack). Shallow or Deep copy ? James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-07-16 10:30 -0700
Re: [niubbo] aggregate types built in a function and returned by value (on stack). Shallow or Deep copy ? Soviet_Mario <SovietMario@CCCP.MIR> - 2019-07-16 19:44 +0200
Re: [niubbo] aggregate types built in a function and returned by value (on stack). Shallow or Deep copy ? Rosario19 <Ros@invalid.invalid> - 2019-07-23 09:28 +0200
Re: [niubbo] aggregate types built in a function and returned by value (on stack). Shallow or Deep copy ? Öö Tiib <ootiib@hot.ee> - 2019-07-15 20:22 -0700
Re: [niubbo] aggregate types built in a function and returned by value (on stack). Shallow or Deep copy ? Soviet_Mario <SovietMario@CCCP.MIR> - 2019-07-16 14:37 +0200
Re: [niubbo] aggregate types built in a function and returned by value (on stack). Shallow or Deep copy ? Öö Tiib <ootiib@hot.ee> - 2019-07-17 01:41 -0700
Re: [niubbo] aggregate types built in a function and returned by value (on stack). Shallow or Deep copy ? Paavo Helde <myfirstname@osa.pri.ee> - 2019-07-16 15:04 +0300
Re: [niubbo] aggregate types built in a function and returned by value (on stack). Shallow or Deep copy ? Soviet_Mario <SovietMario@CCCP.MIR> - 2019-07-16 14:42 +0200
Re: [niubbo] aggregate types built in a function and returned by value (on stack). Shallow or Deep copy ? Paavo Helde <myfirstname@osa.pri.ee> - 2019-07-16 16:15 +0300
Re: [niubbo] aggregate types built in a function and returned by value (on stack). Shallow or Deep copy ? James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-07-16 10:07 -0400
Re: [niubbo] aggregate types built in a function and returned by value (on stack). Shallow or Deep copy ? Juha Nieminen <nospam@thanks.invalid> - 2019-07-17 07:36 +0000
csiph-web