[Development] unique_ptr and Qt, Take 2
Thiago Macieira
thiago.macieira at intel.com
Fri May 3 21:10:52 CEST 2019
On Friday, 3 May 2019 11:41:16 PDT Иван Комиссаров wrote:
> auto button = layout->addWidget(make_unique<QPushButton>(«RIGHT»));
> button->setFlat(true);
The problem with code that has pre- and post-addition setup is that now you
have two objects in the stack, which complicates your stack frame. The
compilers aren't currently smart enough to deduce std::unique_ptr whose
payload is completely null and can be early-destroyed.
I'm wary of making user code less readable, but it's something we should do if
it's for a good reason.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel System Software Products
More information about the Development
mailing list