mardi 31 janvier 2017

Is there any way to trick std::make_shared into using default initialization?

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