...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
A dynamically sized array of JSON values.
Defined in header <boost/json/array.hpp>
class array
Name |
Description |
---|---|
The type of Allocator returned by |
|
A random access const iterator to an element. |
|
A const pointer to an element. |
|
A const reference to an element. |
|
A reverse random access const iterator to an element. |
|
The type used to represent signed integers. |
|
A random access iterator to an element. |
|
A pointer to an element. |
|
A reference to an element. |
|
A reverse random access iterator to an element. |
|
The type used to represent unsigned integers. |
|
The type of each element. |
Name |
Description |
---|---|
array [constructor] |
Constructor. |
Access an element, with bounds checking. |
|
Access the last element. |
|
Return an iterator to the first element. |
|
Return the number of elements that can be held in currently allocated memory. |
|
Return a const iterator to the first element. |
|
Return a const iterator to the element following the last element. |
|
Clear the contents. |
|
Return a const reverse iterator to the first element of the reversed container. |
|
Return a const reverse iterator to the element following the last element of the reversed container. |
|
Access the underlying array directly. |
|
Insert a constructed element in-place. |
|
Append a constructed element in-place. |
|
Check if the array has no elements. |
|
Return an iterator to the element following the last element.
|
|
Erase elements from the container. |
|
Access the first element. |
|
Return the associated |
|
Return a pointer to an element, or nullptr if the index is invalid. |
|
Insert elements before the specified location. |
|
Copy assignment. |
|
Access an element. |
|
Remove the last element. |
|
Add an element to the end. |
|
Return a reverse iterator to the first element of the reversed
container. |
|
Return a reverse iterator to the element following the last element
of the reversed container. |
|
Increase the capacity to at least a certain amount. |
|
Change the number of elements stored. |
|
Request the removal of unused capacity. |
|
Return the number of elements in the array. |
|
Return the associated |
|
Swap the contents. |
|
~array [destructor] |
Destructor. |
Name |
Description |
---|---|
Return the maximum number of elements any array can hold. |
Name |
Description |
---|---|
Return |
|
Return |
|
Exchange the given values. |
This is the type used to represent a JSON array as a modifiable container.
The interface and performance characteristics are modeled after std::vector<value>
.
Elements are stored contiguously, which means that they can be accessed not
only through iterators, but also using offsets to regular pointers to elements.
A pointer to an element of an array
may be passed to any function
that expects a pointer to value
.
The storage of the array is handled automatically, being expanded and contracted
as needed. Arrays usually occupy more space than array language constructs,
because more memory is allocated to handle future growth. This way an array
does not need to reallocate each time an element is inserted, but only when
the additional memory is used up. The total amount of allocated memory can
be queried using the capacity
function. Extra memory
can be relinquished by calling shrink_to_fit
.
Reallocations are usually costly operations in terms of performance. The
reserve
function can be used to eliminate reallocations if the number of elements
is known beforehand.
The complexity (efficiency) of common operations on arrays is as follows:
All elements stored in the container, and their children if any, will use the same memory resource that was used to construct the container.
Non-const member functions may not be called concurrently with any other member functions.
ContiguousContainer, ReversibleContainer, and SequenceContainer.
Convenience header <boost/json.hpp>