The coding standards are the least of your worries!
The coding standards are the least of your worries!
Posted Jun 1, 2010 17:04 UTC (Tue) by Ed_L. (guest, #24287)In reply to: The coding standards are the least of your worries! by Ed_L.
Parent article: GCC begins move to C++
Yes, I meant the try block must surround the scope of any auto object whose constructor might throw. Certainly
C_Bar *pfoo;
try{
pfoo = new(C_Bar);
}catch(...){};
will work just fine. But I *like* auto objects....
And yes, if used an Init() method may return a status flag rather than throw an exception.
Posted Jun 1, 2010 17:13 UTC (Tue)
by Ed_L. (guest, #24287)
[Link]
pfoo = new C_Bar();
(Its what I get for writing code fragments without a compiler...)
Posted Jun 2, 2010 18:27 UTC (Wed)
by Cyberax (✭ supporter ✭, #52523)
[Link]
std::auto_ptr<C_BAR> bar(new C_Bar());
...or something like it. It's exception- and leak-proof.
In one of my projects we had a 'no naked new' rule. So the result of EACH 'new' must be wrapped in a smart pointer (there were only a few carefully audited places where this policy was relaxed). Worked wonders.
The coding standards are the least of your worries!
The coding standards are the least of your worries!