[Development] std::allocate_shared for QSharedPointer

Sean Harmer sean.harmer at kdab.com
Sat Sep 9 10:46:49 CEST 2017


Hi,

I have a use case where we need to create, use and destroy a relatively 
large number of QSharedPointers rapidly. To avoid the malloc overhead it 
would be nice to be able to use a pool of QSharedPointers.

We have QSharedPointer::create() which is analogous to 
std::make_shared() that allows to reduce creating a QSharedPointer and 
the object it points at to a single memory allocation.

However, this uses operator new internally. I can't see any equivalent 
of std::allocate_shared() which would allow the use of a custom 
allocator for the QSP and object memory allocation.

Does anybody have any plans to add such a facility? Or is there some 
other facility to avoid operator new here for both the QSP and the 
object itself?

Thanks,

Sean
-- 
Dr Sean Harmer | sean.harmer at kdab.com | Managing Director UK
KDAB (UK) Ltd, a KDAB Group company
Tel. +44 (0)1625 809908; Sweden (HQ) +46-563-540090
Mobile: +44 (0)7545 140604
KDAB - Qt Experts



More information about the Development mailing list