lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] PATCH: use std::uncaught_exceptions()


From: Greg Chicares
Subject: Re: [lmi] PATCH: use std::uncaught_exceptions()
Date: Thu, 5 Apr 2018 01:21:34 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 2018-04-02 13:21, Vadim Zeitlin wrote:
> On Mon, 2 Apr 2018 00:52:46 +0000 Greg Chicares <address@hidden> wrote:
> 
> GC> As I see it, "use dtors only for releasing resources" is a best practice,
> GC> and contravening a best practice for convenience is an unfavorable 
> tradeoff.
> 
>  I disagree.

I see that you really have thought through the ramifications thoroughly,
and that yours is a tenable position. However, I'm not going to embrace it:
convenient though it may be, I'm still persuaded by this reasoning:

> GC> http://www.gotw.ca/gotw/047.htm
> GC> | My major problem with this solution is not technical, but moral:
> GC> | It is poor design to give T::~T() two different semantics ...

Even if we could follow this pattern rigorously, with no deviation ever:

   class C {int const exception_count_;};

   C::C() : exception_count_(std::uncaught_exceptions()) {}
 
   C::~C() noexcept(false) // 'noexcept' similarly for any base class
   {
     if(exception_count_ != std::uncaught_exceptions())
       try { commit_changes(); }
       catch(...) { notification_that_cannot_conceivably_throw(); }
     release_resources();
   }

it's still too confusing IMO to justify the potential benefits.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]