
29 Jun
2009
29 Jun
'09
11:51 a.m.
Christian Schladetsch wrote:
boost::variant doesnt support custom allocators. it uses naked new and delete.
variant stores objects within itself. If you declare a variant on the stack, your object lies on the stack. The temporary heap backup is only there in operator= and only when you don't have a nothrow move or nothrow default constructor on one of your types. And it's only used for a few instructions unless you throw anyway, so who cares about what allocator it uses. Alternatively, it could also store the backup in the object itself to avoid heap allocations, but that would double its size.