Hello Eike, * > Hi Daniel, > > On Thu, Aug 04, 2005 at 18:00:21 +0200, Daniel Bölzle wrote: > > >>additional tip: always catch by reference (Exception &), saving an extra >>copy construction. > > > Not only saving copy construction, but also preventing slicing off > derived classes in case only a base class is caught and the exception is > re-thrown. Also matters if the exception is modified and re-thrown, the > modifications would be lost. >
Yes. Also worth mentioning in this context is that (most often) a temporary is constructed and thrown ("most often", because this temporary may be eliminated: standard 15.1.5). This may become a trap, e.g. even catching by reference in the following sample does not do the intended: MyExc e; try { throw e; } catch (MyExc & r) { r.modify(); } // e is left _unmodified_! -Daniel --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]