Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

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: Requires working SFINAE (i.e. BOOST_NO_SFINAE is not set). Only a minority of rather old compilers do not support this. Also known to be broken with the Borland/Codegear compilers.

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.


PrevUpHomeNext