[Interest] What's the recommended way to put QObjects in smart pointers?
Nikos Chantziaras
realnc at gmail.com
Thu May 5 13:22:12 CEST 2016
On 05/05/16 14:24, André Pönitz wrote:
> On Thu, May 05, 2016 at 04:24:48AM +0300, Nikos Chantziaras wrote:
>> Well, basically what I want is not having even a single 'new' or 'delete'
>> anywhere in my code. I already achieved that with all my non-Qt projects.
>
> remedyforirrationalfear.h:
>
> namespace snakeoil {
> template<typename T, typename... Args>
> inline T* make_dynamic_object(Args&&... args)
> { return new T(std::forward<A>(args)...); }
> }
>
> myposhapp.cpp:
>
> #include "remedyforirrationalfear.h"
>
> // Oh Noes! Get out the garlic!
> // auto x = new X(23);
> auto x = snakeoil::make_dynamic_object<X>(23);
>
>> By now, I consider application-level code that uses 'new' or 'delete' as
>> bogus and in need of fixing.
>
> What a happy world we live in.
That doesn't do anything useful. I think you're missing the point here.
More information about the Interest
mailing list