From WikiChip
Difference between revisions of "c++/std/new"
< c++‎ | std

(Created page with "{{DISPLAYTITLE:<new> Header - C++}} {{C++ Standard Library}} The header '''<new>''' defines several functions that can be used to manage dynamic storage in C++. This heade...")
(No difference)

Revision as of 17:17, 2 December 2013

The header <new> defines several functions that can be used to manage dynamic storage in C++. This header provides a relatively low-level memory facilities. In addition to declaring a set of functions within the std namespace, several other functions are defined within the global namespace.

Functions

Function Description Since
operator new allocation functions C++98
operator new[] C++98
operator delete deallocation functions C++98
operator delete[] C++98
get_new_handler retrieves the current new handler C++11
set_new_handler registers a new handler C++11

Synopsis

namespace std {
    class bad_alloc;
    class bad_array_new_length;
    struct nothrow_t {};
    extern const nothrow_t nothrow;
    typedef void (*new_handler)();
    new_handler get_new_handler() noexcept;
    new_handler set_new_handler(new_handler new_p) noexcept;
}

void* operator new(std::size_t size);
void* operator new(std::size_t size, const std::nothrow_t&) noexcept;
void  operator delete(void* ptr) noexcept;
void  operator delete(void* ptr, const std::nothrow_t&) noexcept;
void* operator new[](std::size_t size);
void* operator new[](std::size_t size, const std::nothrow_t&) noexcept;
void  operator delete[](void* ptr) noexcept;
void  operator delete[](void* ptr, const std::nothrow_t&) noexcept;
void* operator new (std::size_t size, void* ptr) noexcept;
void* operator new[](std::size_t size, void* ptr) noexcept;
void  operator delete (void* ptr, void*) noexcept;
void  operator delete[](void* ptr, void*) noexcept;