I want to provide specialized optimizations for allocations done with std::allocator, but if someone has subclassed it without overriding allocate or deallocate, then I don’t know how to detect whether they’re still using std::allocator or not.
How do I do this?
Assuming they haven’t defined their own
allocateanddeallocatefunctions, then one way to test is by testing the valueto test whether the
allocateanddeallocatemethods are the default ones.If they have provided their own functions, then there is no generic way to test.
This solution does not look at the other methods.
It can give you occasional false negatives, but should not give false positives.
My implementation: