From WikiChip
Difference between revisions of "c++/std/new"
Line 1: | Line 1: | ||
{{DISPLAYTITLE:<new> Header - C++}} | {{DISPLAYTITLE:<new> Header - C++}} | ||
{{C++ Standard Library}} | {{C++ Standard Library}} | ||
− | 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]]. | + | The header '''<new>''' defines several functions that can be used to manage dynamic storage in [[C++]] as part of the [[C++ Standard Library]]. 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 == | == Functions == |
Revision as of 19:08, 2 December 2013
The header <new> defines several functions that can be used to manage dynamic storage in C++ as part of the C++ Standard Library. 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.
Contents
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 |
Classes
Class | Description | Since |
---|---|---|
bad_alloc | thrown during a failure of memory allocation | C++98 |
bad_array_new_length | thrown on invalid length allocation | C++11 |
nothrow_t | nothrow type | C++98 |
Objects
Type | Description | Since |
---|---|---|
nothrow | nothrow constant | C++98 |
Types
Type | Description | Since |
---|---|---|
new_handler | type of a new handler function | C++98 |
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;