moya-lang / Allocator

Ultra fast C++11 allocator for STL containers.
BSD 2-Clause "Simplified" License
270 stars 25 forks source link

Trying to use in MSVC unordered multimap #10

Closed WindowsNT closed 4 years ago

WindowsNT commented 4 years ago

Example:

struct M
{
...
};
typedef Moya::Allocator<std::pair<const int,M>, 1024*1024> MemoryPoolAllocator;
std::unordered_multimap<int,M,std::hash<int>,std::equal_to<int>, MemoryPoolAllocator> evs;

Still uses new/delete. It fails there:

            if (!std::is_same<T, U>::value)
                rebindAllocator = new std::allocator<T>();
moya-mmoczala commented 4 years ago

Thank you so much for your effort to start the issue. I will try to look into this as soon as possible.

moya-mmoczala commented 4 years ago

Sorry for long no reply. This mechanism is in _WIN32 only. It allows to workaround MSVC which copies the allocator using other, internal type. For now I have no idea to workaround it in a different way to support unordered_multimap. Only STL containers mentioned in the readme are supported in MSVC. If you have some proposals how to fix it, I will be more than happy if you could contribute.