Detecting if a class overrides free store functions

I want to create a STL allocator that uses a class's static new function if it exists and will fallback on std::allocator::allocate if it doesn't. I think it should be easy to do this with sfinae but I don't see an appropriate type trait to detect if a class provides allocation and deallocation functions. Should these be provided? Maybe boost::has_allocation_function<T> boost::has_deallocation_function<T> or just boost::has_new<T> boost::has_delete<T> -- Michael Marcin

AMDG Mathias Gaunard wrote:
Michael Marcin wrote:
I want to create a STL allocator that uses a class's static new function if it exists and will fallback on std::allocator::allocate if it doesn't.
std::allocator::allocate already uses operator new.
std::allocator::allocate always uses global new. I think the idea is to use T::operator new instead when it exists. In Christ, Steven Watanabe

Steven Watanabe wrote:
AMDG
Mathias Gaunard wrote:
Michael Marcin wrote:
I want to create a STL allocator that uses a class's static new function if it exists and will fallback on std::allocator::allocate if it doesn't.
std::allocator::allocate already uses operator new.
std::allocator::allocate always uses global new. I think the idea is to use T::operator new instead when it exists.
Exactly. -- Michael Marcin
participants (3)
-
Mathias Gaunard
-
Michael Marcin
-
Steven Watanabe