
AMDG Corrado Zoccolo <czoccolo <at> gmail.com> writes:
I think SFINAE is not enough to replicate faithfully the rules employed by the compiler to select the which operator new is called for an expression like new T(a1,..,an) . It will look not only in T, but also in its base classes.
I don't understand. Both "new T" and has_new<T> look in base classes of T. SFINAE seems to work on both msvc 8.0 and gcc 3.4.4 I think that what I would do is create a generic allocator that looks up the correct operator new/delete template<class T, bool = has_new<T>::value> struct my_allocator; template<class T> struct my_allocator<T, true> { T* allocate(std::size_t n) { return(T::operator new(n * sizeof(T))); } void deallocate(T* victim, std::size_t n) { return(T::operator delete(victim, n * sizeof(T))); } //... }; template<class T> struct my_allocator<T, false> { T* allocate(std::size_t n) { return(::operator new(n * sizeof(T))); } void deallocate(T* victim, std::size_t n) { return(::operator delete(victim)); } //... }; In Christ, Steven Watanabe