Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/memory/new"

From cppreference.com
< cpp‎ | memory
m (Update links.)
m (fmt)
 
(5 intermediate revisions by 4 users not shown)
Line 2: Line 2:
 
{{cpp/memory/new/navbar}}
 
{{cpp/memory/new/navbar}}
  
The [[cpp/language/new |new-expression]] is the only way to create an object or an array of objects with dynamic storage duration, that is, with lifetime not restricted to the scope in which it is created. A new-expression obtains storage by calling an allocation function. A [[cpp/language/delete |delete-expression]] destroys a most derived object or an array created by a new-expression and calls the deallocation function. The default allocation and deallocation functions, along with related functions, types, and objects, are declared in the header {{tt|<new>}}.  
+
The [[cpp/language/new |new-expression]] is the only way to create an object or an array of objects with dynamic storage duration, that is, with lifetime not restricted to the scope in which it is created. A new-expression obtains storage by calling an allocation function. A [[cpp/language/delete |delete-expression]] destroys a most derived object or an array created by a new-expression and calls the deallocation function. The default allocation and deallocation functions, along with related functions, types, and objects, are declared in the header {{header|new}}.  
  
 
{{dsc begin}}
 
{{dsc begin}}
{{dsc header |new}}
+
{{dsc header|new}}
{{dsc h2 | Functions}}
+
{{dsc h2|Functions}}
{{dsc inc | cpp/memory/new/dsc operator_new}}
+
{{dsc inc|cpp/memory/new/dsc operator_new}}
{{dsc inc | cpp/memory/new/dsc operator_delete}}
+
{{dsc inc|cpp/memory/new/dsc operator_delete}}
{{dsc inc | cpp/memory/new/dsc get_new_handler}}
+
{{dsc inc|cpp/memory/new/dsc get_new_handler}}
{{dsc inc | cpp/memory/new/dsc set_new_handler}}
+
{{dsc inc|cpp/memory/new/dsc set_new_handler}}
{{dsc h2 | Classes }}
+
{{dsc h2|Classes}}
{{dsc inc | cpp/memory/new/dsc bad_alloc}}
+
{{dsc inc|cpp/memory/new/dsc bad_alloc}}
{{dsc inc | cpp/memory/new/dsc bad_array_new_length}}
+
{{dsc inc|cpp/memory/new/dsc bad_array_new_length}}
{{dsc inc | cpp/memory/new/dsc nothrow_t}}
+
{{dsc inc|cpp/memory/new/dsc align_val_t}}
{{dsc h2 | Types }}
+
{{dsc h2|Types}}
{{dsc inc | cpp/memory/new/dsc new_handler}}
+
{{dsc inc|cpp/memory/new/dsc new_handler}}
{{dsc h2 | Objects}}
+
{{dsc h2|Objects}}
{{dsc inc | cpp/memory/new/dsc nothrow}}
+
{{dsc inc|cpp/memory/new/dsc nothrow}}
 +
{{dsc inc|cpp/memory/new/dsc destroying_delete}}
 +
{{dsc h2|Object access}}
 +
{{dsc inc|cpp/utility/dsc launder}}
 
{{dsc end}}
 
{{dsc end}}
  
[[de:cpp/memory/new]]
+
{{langlinks|de|es|fr|it|ja|pt|ru|zh}}
[[es:cpp/memory/new]]
+
[[fr:cpp/memory/new]]
+
[[it:cpp/memory/new]]
+
[[ja:cpp/memory/new]]
+
[[pt:cpp/memory/new]]
+
[[ru:cpp/memory/new]]
+
[[zh:cpp/memory/new]]
+

Latest revision as of 07:56, 16 December 2023

 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
 
Dynamic memory management
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Allocators
Garbage collection support
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)(until C++23)



 
 

The new-expression is the only way to create an object or an array of objects with dynamic storage duration, that is, with lifetime not restricted to the scope in which it is created. A new-expression obtains storage by calling an allocation function. A delete-expression destroys a most derived object or an array created by a new-expression and calls the deallocation function. The default allocation and deallocation functions, along with related functions, types, and objects, are declared in the header <new>.

Defined in header <new>

Contents

Functions
allocation functions
(function) [edit]
deallocation functions
(function) [edit]
obtains the current new handler
(function) [edit]
registers a new handler
(function) [edit]
Classes
exception thrown when memory allocation fails
(class) [edit]
exception thrown on allocation of array with invalid length
(class) [edit]
type used to pass alignment to alignment-aware allocation and deallocation functions
(enum) [edit]
Types
function pointer type of the new handler
(typedef) [edit]
Objects
a tag used to select a non-throwing allocation function
(tag)[edit]
a tag used to select destroying-delete overloads of operator delete
(tag)[edit]
Object access
(C++17)
pointer optimization barrier
(function template) [edit]