has_new_operator

| Home | Libraries | People | FAQ | More

### has_new_operator

    template <class T>
    struct has_new_operator : public true_type-or-false_type {};

Inherits: If T is a (possibly cv-qualified) type with an overloaded new-operator then inherits from true_type, otherwise inherits from false_type.

Compiler Compatibility: Not usable with compilers that do not support "substitution failure is not an error" (in which case BOOST_NO_SFINAE will be defined), also known to be broken with the Borland/Codegear compiler.

C++ Standard Reference: 12.5.

Header: `#include <boost/type_traits/has_new_operator.hpp>` or `#include <boost/type_traits.hpp>`

Examples:

Given:

    class A { void* operator new(std::size_t); };
    class B { void* operator new(std::size_t, const std::nothrow&); };
    class C { void* operator new(std::size_t, void*); };
    class D { void* operator new[](std::size_t); };
    class E { void* operator new[](std::size_t, const std::nothrow&); };
    class F { void* operator new[](std::size_t, void*); };

Then:

> `has_new_operator<A>` inherits from `true_type`.

> `has_new_operator<B>` inherits from `true_type`.

> `has_new_operator<C>` inherits from `true_type`.

> `has_new_operator<D>` inherits from `true_type`.

> `has_new_operator<E>` inherits from `true_type`.

> `has_new_operator<F>` inherits from `true_type`.