electronicarts / EASTL

EASTL stands for Electronic Arts Standard Template Library. It is an extensive and robust implementation that has an emphasis on high performance.
BSD 3-Clause "New" or "Revised" License
8.09k stars 929 forks source link

Overriding make_unique and default_delete #525

Open equalent opened 7 months ago

equalent commented 7 months ago

There is no way to directly override allocation in make_unique and default_delete.

They directly call standard operators, requiring having custom deleters everywhere or editing the source code when integrating EASTL into any project which involves dynamic linking (as overriding new and delete is not supported for DLLs).

Making them use the default allocator is one very simple solution which would at least provide the same allocation as other EASTL types.

jhopkins-ea commented 7 months ago

make_unique is by definition a utillity to create a new-ed object, which will be deleted by a call to delete. (although eastl::make_unique doesn't perfectly mirror the std::make_unique) the standard proposal that added std::make_unique has a good explanation on why users should simply create their own utility function if they want to use their own allocator & deleter. Specifically, see section 3.4.

equalent commented 7 months ago

Understood. But wouldn't it make more sense to at least make them use the default allocator? This would ensure the entire library has a single default point of allocation, according to the FAQ: EASTL never uses global new / delete / malloc / free. All allocations are done via user-specified allocators, though a default allocator definition is available.