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...")
 
m
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:<new> Header - C++}}
+
{{c++ title|<new> Header}}{{C++ Standard Library}}
{{C++ Standard Library}}
+
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]].
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 ==
 
== Functions ==
Line 20: Line 19:
 
|-
 
|-
 
| [[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;

Latest revision as of 20:16, 26 November 2015

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[edit]

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[edit]

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[edit]

Type Description Since
nothrow nothrow constant C++98

Types[edit]

Type Description Since
new_handler type of a new handler function C++98

Synopsis[edit]

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;