[go: up one dir, main page]

Menu

#9 Don't create exceptions on the heap

closed
nobody
None
True
2015-09-01
2015-08-31
No

Why are there three pieces of code that do this strange dance?

boost::shared_ptr<Exception> ex;
ex.reset( new Exception );
throw *ex.get();

Ignoring the fact that *ex.get() is unnecessarily verbose (what's wrong with just *ex?) why is the exception created on the heap, when it needs to be deleted again right away? Why not just throw an exception directly?

1 Attachments

Discussion

  • Cedric Bosdonnat

    • status: open --> closed
    • Patch: False --> True
     
  • Cedric Bosdonnat

    Pushed to master. Thanks for the patch

     

Log in to post a comment.