Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #67639
| From | "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: newbie question: exceptions |
| Date | 2019-08-14 10:25 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <qj0gh4$1dc$1@dont-email.me> (permalink) |
| References | <qiuhp3$56q7$1@portraits.wsisiz.edu.pl> <qiui12$5702$1@portraits.wsisiz.edu.pl> <grg1nfFeletU1@mid.individual.net> <qj0fdh$nvu1$1@portraits.wsisiz.edu.pl> |
On 14.08.2019 10:06, Jivanmukta wrote: > W dniu 13.08.2019 o 17:02, Bo Persson pisze: >> On 2019-08-13 at 16:38, Jivanmukta wrote: >>> W dniu 13.08.2019 o 16:34, Jivanmukta pisze: > >>>> throw exception(); > >> >> You can do either - throw an exception object or throw a pointer. >> >> In the latter case you have to catch a pointer and also remember to >> delete it somewhere. Extra work. And an extra allocation. >> >> So most people prefer the first version. > > Do you mean that in the line: > > throw exception(); > > I create automatic object of a class exception? You're creating a temporary, that's copied/moved somewhere. Throwing is anyway a high cost operation. Whether it involves dynamic allocation internally depends on the C++ implementation. Your responsibility ends with the creation of the temporary. Any memory management after that is automatic. Of course, it relies on assumed correctness of copy constructor and/or move constructor. Cheers!, - ALf
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
newbie question: exceptions Jivanmukta <jivanmukta@poczta.onet.pl> - 2019-08-13 16:34 +0200
Re: newbie question: exceptions Jivanmukta <jivanmukta@poczta.onet.pl> - 2019-08-13 16:38 +0200
Re: newbie question: exceptions Bo Persson <bo@bo-persson.se> - 2019-08-13 17:02 +0200
Re: newbie question: exceptions Jivanmukta <jivanmukta@poczta.onet.pl> - 2019-08-14 10:06 +0200
Re: newbie question: exceptions "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-08-14 10:25 +0200
Re: newbie question: exceptions James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-08-14 08:41 -0400
Re: newbie question: exceptions "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-08-14 19:39 +0200
Re: newbie question: exceptions James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-08-14 19:47 -0400
Re: newbie question: exceptions "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-08-15 05:13 +0200
Re: newbie question: exceptions Jorgen Grahn <grahn+nntp@snipabacken.se> - 2019-08-14 10:18 +0000
Re: newbie question: exceptions Öö Tiib <ootiib@hot.ee> - 2019-08-13 08:03 -0700
Re: newbie question: exceptions Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-08-17 22:07 -0700
Re: newbie question: exceptions Öö Tiib <ootiib@hot.ee> - 2019-08-17 23:18 -0700
Re: newbie question: exceptions Öö Tiib <ootiib@hot.ee> - 2019-08-18 00:05 -0700
Re: newbie question: exceptions Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-08-18 05:18 -0700
Re: newbie question: exceptions Bonita Montero <Bonita.Montero@gmail.com> - 2019-08-13 17:39 +0200
Re: newbie question: exceptions Szyk Cech <szykcech@spoko.pl> - 2019-08-13 17:01 +0200
Re: newbie question: exceptions Szyk Cech <szykcech@spoko.pl> - 2019-08-13 17:03 +0200
Re: newbie question: exceptions Bonita Montero <Bonita.Montero@gmail.com> - 2019-08-13 17:03 +0200
Re: newbie question: exceptions red floyd <dont.bother@its.invalid> - 2019-08-13 09:33 -0700
Re: newbie question: exceptions Melzzzzz <Melzzzzz@zzzzz.com> - 2019-08-14 00:37 +0000
Re: newbie question: exceptions Rosario19 <Ros@invalid.invalid> - 2019-08-24 08:32 +0200
Re: newbie question: exceptions Melzzzzz <Melzzzzz@zzzzz.com> - 2019-08-24 11:30 +0000
Re: newbie question: exceptions red floyd <dont.bother@its.invalid> - 2019-08-26 10:29 -0700
csiph-web