[Interest] What's the recommended way to put QObjects in smart pointers?

Nikos Chantziaras realnc at gmail.com
Fri May 13 01:51:31 CEST 2016


On 12/05/16 10:35, Jean-Michaƫl Celerier wrote:
>
> On Wed, May 11, 2016 at 9:56 PM, Nikos Chantziaras <realnc at gmail.com
> <mailto:realnc at gmail.com>> wrote:
>
>
>     This results in code duplication, since you write the same cleanup
>     code everywhere.
>
>
> I'd argue that if you use RAII and have cleanup code in more than one
> place, you are not using RAII.
> But could you give an example of this ?


SCOPE_GUARD { foo; bar; baz }

...

SCOPE_GUARD { foo; bar; baz }

...

SCOPE_GUARD { foo; bar; baz }

etc :-)

Scope guards are useful for one-off things, not for cleanup code you 
would need to write over and over again.




More information about the Interest mailing list