You are expected to use std::make_shared to ensure that block with counters is stored next to data. Unfortunately internally std::make_shared uses zero initialization for T (i.e. uses T() to initialize data block). Is there any way to trick it into using default initialization? I know I can use std::shared_ptr( new T, [](auto p){delete p;}), but I'll end up with two allocations here (data and counter blocks won't be next to each other)
Aucun commentaire:
Enregistrer un commentaire