[Development] unique_ptr and Qt, Take 2
abbapoh at gmail.com
Fri May 3 23:26:40 CEST 2019
Or maybe you can’t I didn’t think about the fact that public ctor allocates d_ptr itself… Need to think a bit more=(
> 3 мая 2019 г., в 23:03, Иван Комиссаров <abbapoh at gmail.com> написал(а):
> You can use the same technique in qMakeChild as in std::make_shared - to allocate MyObjectPrivate and space for the d_ptr in one go. Probably will require some additional macroses, though, to hide the implementation (sizeof(MyObjectPrivate)) in the cpp file.
> I’d say it’s an implementation detail - it *is* possible to implement the creation of QObjects more efficient than it is done now without «forcing» user to use objects on stack to avoid allocations.
More information about the Development