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...")
 
Line 20: Line 20:
 
|-
 
|-
 
| [[New/set_new_handler - C++|set_new_handler]] || registers a new handler || [[C++11]]
 
| [[New/set_new_handler - C++|set_new_handler]] || registers a new handler || [[C++11]]
 +
|}
 +
 +
== Classes ==
 +
{| class="wikitable"
 +
|-
 +
! Class !! Description !! Since
 +
|-
 +
| [[New/bad_alloc - C++|bad_alloc]] || thrown during a failure of memory allocation || [[C++98]]
 +
|-
 +
| [[New/bad_array_new_length - C++|bad_array_new_length]] || thrown on invalid length allocation || [[C++11]]
 +
|-
 +
| [[New/nothrow_t - C++|nothrow_t]] || nothrow type || [[C++98]]
 +
|}
 +
 +
== Objects ==
 +
{| class="wikitable"
 +
|-
 +
! Type !! Description !! Since
 +
|-
 +
| [[New/nothrow - C++|nothrow]] || nothrow constant || [[C++98]]
 +
|}
 +
 +
== Types ==
 +
{| class="wikitable"
 +
|-
 +
! Type !! Description !! Since
 +
|-
 +
| [[New/new_handler - C++|new_handler]] || type of a new handler function || [[C++98]]
 
|}
 
|}
  
 
== Synopsis ==
 
== Synopsis ==
<source lang="c">namespace std {
+
<source lang="cpp">namespace std {
 
     class bad_alloc;
 
     class bad_alloc;
 
     class bad_array_new_length;
 
     class bad_array_new_length;

Revision as of 20:03, 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

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;