[Development] Go's "defer" statement for C++/Qt
timur.pocheptsov at qt.io
Fri Mar 8 06:47:23 CET 2019
Tor Arne +2! :D
From: Development [development-bounces at qt-project.org] on behalf of Jason H [jhihn at gmx.com]
Sent: Thursday, March 7, 2019 11:59 PM
To: Tor Arne Vestbø
Cc: Qt development mailing list
Subject: Re: [Development] Go's "defer" statement for C++/Qt
The verbiage in the example is wrong:
Took me a moment to figure out just what it meant.
> Sent: Thursday, March 07, 2019 at 12:09 PM
> From: "Tor Arne Vestbø" <Tor.arne.Vestbo at qt.io>
> To: "Volker Hilsheimer" <volker.hilsheimer at qt.io>
> Cc: "Qt development mailing list" <development at qt-project.org>
> Subject: Re: [Development] Go's "defer" statement for C++/Qt
> https://doc.qt.io/qt-5/qscopeguard.html 😊
> Tor Arne
> > On 7 Mar 2019, at 18:01, Volker Hilsheimer <volker.hilsheimer at qt.io> wrote:
> > Ahoy,
> > In what little development I’ve done in golang, I appreciated the “defer” statement as a means to write cleaner code. Basically, defer schedules a statement for execution when the stack unwinds.
> > https://tour.golang.org/flowcontrol/12
> > We have several specialized helper classes in Qt for similar purposes, f.ex QMutexLocker and friends, or the internal QBoolBlocker . Seeing the various specialized classes we have, I thought that something generic in Qt could be useful to have (although our specialised classes provide some additional convenience and/or logic).
> > So, I pushed a few lines code to
> > https://git.qt.io/vohilshe/qt_defer
> > Would like to hear what you think.
> > Perhaps someone can find ways to make this more elegant without introducing tons of preprocessor/macro shenanigans, or perhaps even without depending on C++17's implicit template argument deduction (without enabling C++17 in the config this doesn't build for me, even though I don’t use auto in the template paramter list).
> > Cheers,
> > Volker
> >  which was requested to be made public in https://bugreports.qt.io/browse/QTBUG-38575
> > _______________________________________________
> > Development mailing list
> > Development at qt-project.org
> > https://lists.qt-project.org/listinfo/development
> Development mailing list
> Development at qt-project.org
Development mailing list
Development at qt-project.org
More information about the Development