26349 lines
600 KiB
Plaintext
26349 lines
600 KiB
Plaintext
|
||
[section:boost__json__array array]
|
||
|
||
A dynamically sized array of JSON values.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/array.hpp]
|
||
|
||
```
|
||
class array
|
||
```
|
||
|
||
[heading Types]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__array.allocator_type allocator_type]]
|
||
]
|
||
[The type of ['Allocator] returned by [link json.ref.boost__json__array.get_allocator `get_allocator`].
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.const_iterator const_iterator]]
|
||
]
|
||
[A random access const iterator to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.const_pointer const_pointer]]
|
||
]
|
||
[A const pointer to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.const_reference const_reference]]
|
||
]
|
||
[A const reference to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.const_reverse_iterator const_reverse_iterator]]
|
||
]
|
||
[A reverse random access const iterator to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.difference_type difference_type]]
|
||
]
|
||
[The type used to represent signed integers.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.iterator iterator]]
|
||
]
|
||
[A random access iterator to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.pointer pointer]]
|
||
]
|
||
[A pointer to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.reference reference]]
|
||
]
|
||
[A reference to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.reverse_iterator reverse_iterator]]
|
||
]
|
||
[A reverse random access iterator to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.size_type size_type]]
|
||
]
|
||
[The type used to represent unsigned integers.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.value_type value_type]]
|
||
]
|
||
[The type of each element.
|
||
]
|
||
]
|
||
]
|
||
[heading Member Functions]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__array.array array] [role silver \[constructor\]]]
|
||
]
|
||
[Constructor. [br][role silver —][br]Copy constructor. [br][role silver —][br]Pilfer constructor. [br][role silver —][br]Move constructor.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.at at]]
|
||
]
|
||
[Access an element, with bounds checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.back back]]
|
||
]
|
||
[Access the last element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.begin begin]]
|
||
]
|
||
[Return an iterator to the first element. [br][role silver —][br]Return a const iterator to the first element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.capacity capacity]]
|
||
]
|
||
[Return the number of elements that can be held in currently allocated memory.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.cbegin cbegin]]
|
||
]
|
||
[Return a const iterator to the first element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.cend cend]]
|
||
]
|
||
[Return a const iterator to the element following the last element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.clear clear]]
|
||
]
|
||
[Clear the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.crbegin crbegin]]
|
||
]
|
||
[Return a const reverse iterator to the first element of the reversed container.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.crend crend]]
|
||
]
|
||
[Return a const reverse iterator to the element following the last element of the reversed container.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.data data]]
|
||
]
|
||
[Access the underlying array directly.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.emplace emplace]]
|
||
]
|
||
[Insert a constructed element in-place.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.emplace_back emplace_back]]
|
||
]
|
||
[Append a constructed element in-place.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.empty empty]]
|
||
]
|
||
[Check if the array has no elements.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.end end]]
|
||
]
|
||
[Return an iterator to the element following the last element. [br][role silver —][br]Return a const iterator to the element following the last element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.erase erase]]
|
||
]
|
||
[Erase elements from the container.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.front front]]
|
||
]
|
||
[Access the first element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.get_allocator get_allocator]]
|
||
]
|
||
[Return the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.if_contains if_contains]]
|
||
]
|
||
[Return a pointer to an element, or nullptr if the index is invalid.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.insert insert]]
|
||
]
|
||
[Insert elements before the specified location.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.operator_eq_ operator=]]
|
||
]
|
||
[Copy assignment. [br][role silver —][br]Move assignment. [br][role silver —][br]Assignment.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.operator_lb__rb_ operator\[\]]]
|
||
]
|
||
[Access an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.pop_back pop_back]]
|
||
]
|
||
[Remove the last element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.push_back push_back]]
|
||
]
|
||
[Add an element to the end.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.rbegin rbegin]]
|
||
]
|
||
[Return a reverse iterator to the first element of the reversed container. [br][role silver —][br]Return a const reverse iterator to the first element of the reversed container.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.rend rend]]
|
||
]
|
||
[Return a reverse iterator to the element following the last element of the reversed container. [br][role silver —][br]Return a const reverse iterator to the element following the last element of the reversed container.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.reserve reserve]]
|
||
]
|
||
[Increase the capacity to at least a certain amount.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.resize resize]]
|
||
]
|
||
[Change the number of elements stored.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.shrink_to_fit shrink_to_fit]]
|
||
]
|
||
[Request the removal of unused capacity.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.size size]]
|
||
]
|
||
[Return the number of elements in the array.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.storage storage]]
|
||
]
|
||
[Return the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.swap swap]]
|
||
]
|
||
[Swap the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array._array ~array] [role silver \[destructor\]]]
|
||
]
|
||
[Destructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Static Members]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__array.max_size max_size]]
|
||
]
|
||
[Return the maximum number of elements any array can hold.
|
||
]
|
||
]
|
||
]
|
||
[heading Friends]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__array.operator_not__eq_ operator!=]]
|
||
]
|
||
[Return `true` if two arrays are not equal.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.operator_eq__eq_ operator==]]
|
||
]
|
||
[Return `true` if two arrays are equal.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__array.swap swap]]
|
||
]
|
||
[Exchange the given values.
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
|
||
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 [link json.ref.boost__json__array `array`] may be passed to any function that expects a pointer to [link json.ref.boost__json__value `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 [link json.ref.boost__json__array.capacity `capacity`] function. Extra memory can be relinquished by calling [link json.ref.boost__json__array.shrink_to_fit `shrink_to_fit`].
|
||
|
||
|
||
Reallocations are usually costly operations in terms of performance. The [link json.ref.boost__json__array.reserve `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:
|
||
|
||
* Random access - constant ['O(1)].
|
||
* Insertion or removal of elements at the end - amortized constant ['O(1)].
|
||
* Insertion or removal of elements - linear in the distance to the end of the array ['O(n)].
|
||
|
||
[heading Allocators]
|
||
|
||
All elements stored in the container, and their children if any, will use the same memory resource that was used to construct the container.
|
||
|
||
[heading Thread Safety]
|
||
|
||
Non-const member functions may not be called concurrently with any other member functions.
|
||
|
||
[heading Satisfies]
|
||
[@https://en.cppreference.com/w/cpp/named_req/ContiguousContainer ['ContiguousContainer]], [@https://en.cppreference.com/w/cpp/named_req/ReversibleContainer ['ReversibleContainer]], and [@https://en.cppreference.com/w/cpp/named_req/SequenceContainer ['SequenceContainer]].
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
[section:allocator_type array::allocator_type]
|
||
[indexterm2 allocator_type..array]
|
||
|
||
|
||
The type of ['Allocator] returned by [link json.ref.boost__json__array.get_allocator `get_allocator`].
|
||
[heading Synopsis]
|
||
```
|
||
using allocator_type = ``['see-below]``;
|
||
```
|
||
|
||
[heading Description]
|
||
This type is a [link json.ref.boost__json__polymorphic_allocator `polymorphic_allocator`].
|
||
|
||
[endsect]
|
||
|
||
[section:size_type array::size_type]
|
||
[indexterm2 size_type..array]
|
||
|
||
|
||
The type used to represent unsigned integers.
|
||
[heading Synopsis]
|
||
```
|
||
using size_type = std::size_t;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:value_type array::value_type]
|
||
[indexterm2 value_type..array]
|
||
|
||
|
||
The type of each element.
|
||
[heading Synopsis]
|
||
```
|
||
using value_type = value;
|
||
```
|
||
|
||
[heading Types]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__value.allocator_type allocator_type]]
|
||
]
|
||
[The type of ['Allocator] returned by [link json.ref.boost__json__value.get_allocator `get_allocator`].
|
||
]
|
||
]
|
||
]
|
||
[heading Member Functions]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_array as_array]]
|
||
]
|
||
[Return a reference to the underlying [link json.ref.boost__json__array `array`], or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_bool as_bool]]
|
||
]
|
||
[Return a reference to the underlying `bool`, or throw an exception. [br][role silver —][br]Return the underlying `bool`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_double as_double]]
|
||
]
|
||
[Return a reference to the underlying `double`, or throw an exception. [br][role silver —][br]Return the underlying `double`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_int64 as_int64]]
|
||
]
|
||
[Return a reference to the underlying `std::int64_t`, or throw an exception. [br][role silver —][br]Return the underlying `std::int64_t`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_object as_object]]
|
||
]
|
||
[Return a reference to the underlying `object`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_string as_string]]
|
||
]
|
||
[Return a reference to the underlying `string`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_uint64 as_uint64]]
|
||
]
|
||
[Return a reference to the underlying `std::uint64_t`, or throw an exception. [br][role silver —][br]Return the underlying `std::uint64_t`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.at at]]
|
||
]
|
||
[Access an element, with bounds checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_array emplace_array]]
|
||
]
|
||
[Return a reference to an [link json.ref.boost__json__array `array`], changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_bool emplace_bool]]
|
||
]
|
||
[Return a reference to a `bool`, changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_double emplace_double]]
|
||
]
|
||
[Return a reference to a `double`, changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_int64 emplace_int64]]
|
||
]
|
||
[Return a reference to a `std::int64_t`, changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_null emplace_null]]
|
||
]
|
||
[Change the kind to null, discarding the previous contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_object emplace_object]]
|
||
]
|
||
[Return a reference to an [link json.ref.boost__json__object `object`], changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_string emplace_string]]
|
||
]
|
||
[Return a reference to a [link json.ref.boost__json__string `string`], changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_uint64 emplace_uint64]]
|
||
]
|
||
[Return a reference to a `std::uint64_t`, changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_allocator get_allocator]]
|
||
]
|
||
[Return the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_array get_array]]
|
||
]
|
||
[Return a reference to the underlying `array`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_bool get_bool]]
|
||
]
|
||
[Return a reference to the underlying `bool`, without checking. [br][role silver —][br]Return the underlying `bool`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_double get_double]]
|
||
]
|
||
[Return a reference to the underlying `double`, without checking. [br][role silver —][br]Return the underlying `double`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_int64 get_int64]]
|
||
]
|
||
[Return a reference to the underlying `std::int64_t`, without checking. [br][role silver —][br]Return the underlying `std::int64_t`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_object get_object]]
|
||
]
|
||
[Return a reference to the underlying `object`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_string get_string]]
|
||
]
|
||
[Return a reference to the underlying `string`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_uint64 get_uint64]]
|
||
]
|
||
[Return a reference to the underlying `std::uint64_t`, without checking. [br][role silver —][br]Return the underlying `std::uint64_t`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_array if_array]]
|
||
]
|
||
[Return an [link json.ref.boost__json__array `array`] pointer if this is an array, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_bool if_bool]]
|
||
]
|
||
[Return a `bool` pointer if this is a boolean, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_double if_double]]
|
||
]
|
||
[Return a `double` pointer if this is a double, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_int64 if_int64]]
|
||
]
|
||
[Return an `int64_t` pointer if this is a signed integer, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_object if_object]]
|
||
]
|
||
[Return an [link json.ref.boost__json__object `object`] pointer if this is an object, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_string if_string]]
|
||
]
|
||
[Return a [link json.ref.boost__json__string `string`] pointer if this is a string, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_uint64 if_uint64]]
|
||
]
|
||
[Return a `uint64_t` pointer if this is an unsigned integer, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_array is_array]]
|
||
]
|
||
[Return `true` if this is an array.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_bool is_bool]]
|
||
]
|
||
[Return `true` if this is a bool.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_double is_double]]
|
||
]
|
||
[Return `true` if this is a double.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_int64 is_int64]]
|
||
]
|
||
[Return `true` if this is a signed integer.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_null is_null]]
|
||
]
|
||
[Returns true if this is a null.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_number is_number]]
|
||
]
|
||
[Returns true if this is a number.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_object is_object]]
|
||
]
|
||
[Return `true` if this is an object.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_primitive is_primitive]]
|
||
]
|
||
[Returns true if this is not an array or object.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_string is_string]]
|
||
]
|
||
[Return `true` if this is a string.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_structured is_structured]]
|
||
]
|
||
[Returns true if this is an array or object.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_uint64 is_uint64]]
|
||
]
|
||
[Return `true` if this is a unsigned integer.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.kind kind]]
|
||
]
|
||
[Returns the kind of this JSON value.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.operator_eq_ operator=]]
|
||
]
|
||
[Assignment. [br][role silver —][br]Copy assignment. [br][role silver —][br]Move assignment.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.storage storage]]
|
||
]
|
||
[Return the memory resource associated with the value.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.swap swap]]
|
||
]
|
||
[Swap the given values.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.to_number to_number]]
|
||
]
|
||
[Return the stored number cast to an arithmetic type.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.value value]]
|
||
]
|
||
[Default constructor. [br][role silver —][br]Constructor. [br][role silver —][br]Pilfer constructor. [br][role silver —][br]Copy constructor. [br][role silver —][br]Move constructor. [br][role silver —][br]Construct a null. [br][role silver —][br]Construct a bool. [br][role silver —][br]Construct a `std::int64_t`. [br][role silver —][br]Construct a `std::uint64_t`. [br][role silver —][br]Construct a `double`. [br][role silver —][br]Construct a [link json.ref.boost__json__string `string`]. [br][role silver —][br]Construct an [link json.ref.boost__json__array `array`]. [br][role silver —][br]Construct an [link json.ref.boost__json__object `object`]. [br][role silver —][br]Construct from an initializer-list.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value._value ~value] [role silver \[destructor\]]]
|
||
]
|
||
[Destructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Friends]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__value.operator_not__eq_ operator!=]]
|
||
]
|
||
[Return `true` if two values are not equal.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.operator_eq__eq_ operator==]]
|
||
]
|
||
[Return `true` if two values are equal.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.swap swap]]
|
||
]
|
||
[Swap the given values.
|
||
]
|
||
]
|
||
]
|
||
This is a [@https://en.cppreference.com/w/cpp/concepts/regular ['Regular]]. ['Regular] type which works like a variant of the basic JSON data types: array, object, string, number, boolean, and null.
|
||
|
||
[heading Thread Safety]
|
||
|
||
Distinct instances may be accessed concurrently. Non-const member functions of a shared instance may not be called concurrently with any other member functions of that instance.
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:difference_type array::difference_type]
|
||
[indexterm2 difference_type..array]
|
||
|
||
|
||
The type used to represent signed integers.
|
||
[heading Synopsis]
|
||
```
|
||
using difference_type = std::ptrdiff_t;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:reference array::reference]
|
||
[indexterm2 reference..array]
|
||
|
||
|
||
A reference to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using reference = value&;
|
||
```
|
||
|
||
[heading Types]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__value.allocator_type allocator_type]]
|
||
]
|
||
[The type of ['Allocator] returned by [link json.ref.boost__json__value.get_allocator `get_allocator`].
|
||
]
|
||
]
|
||
]
|
||
[heading Member Functions]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_array as_array]]
|
||
]
|
||
[Return a reference to the underlying [link json.ref.boost__json__array `array`], or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_bool as_bool]]
|
||
]
|
||
[Return a reference to the underlying `bool`, or throw an exception. [br][role silver —][br]Return the underlying `bool`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_double as_double]]
|
||
]
|
||
[Return a reference to the underlying `double`, or throw an exception. [br][role silver —][br]Return the underlying `double`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_int64 as_int64]]
|
||
]
|
||
[Return a reference to the underlying `std::int64_t`, or throw an exception. [br][role silver —][br]Return the underlying `std::int64_t`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_object as_object]]
|
||
]
|
||
[Return a reference to the underlying `object`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_string as_string]]
|
||
]
|
||
[Return a reference to the underlying `string`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_uint64 as_uint64]]
|
||
]
|
||
[Return a reference to the underlying `std::uint64_t`, or throw an exception. [br][role silver —][br]Return the underlying `std::uint64_t`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.at at]]
|
||
]
|
||
[Access an element, with bounds checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_array emplace_array]]
|
||
]
|
||
[Return a reference to an [link json.ref.boost__json__array `array`], changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_bool emplace_bool]]
|
||
]
|
||
[Return a reference to a `bool`, changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_double emplace_double]]
|
||
]
|
||
[Return a reference to a `double`, changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_int64 emplace_int64]]
|
||
]
|
||
[Return a reference to a `std::int64_t`, changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_null emplace_null]]
|
||
]
|
||
[Change the kind to null, discarding the previous contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_object emplace_object]]
|
||
]
|
||
[Return a reference to an [link json.ref.boost__json__object `object`], changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_string emplace_string]]
|
||
]
|
||
[Return a reference to a [link json.ref.boost__json__string `string`], changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_uint64 emplace_uint64]]
|
||
]
|
||
[Return a reference to a `std::uint64_t`, changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_allocator get_allocator]]
|
||
]
|
||
[Return the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_array get_array]]
|
||
]
|
||
[Return a reference to the underlying `array`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_bool get_bool]]
|
||
]
|
||
[Return a reference to the underlying `bool`, without checking. [br][role silver —][br]Return the underlying `bool`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_double get_double]]
|
||
]
|
||
[Return a reference to the underlying `double`, without checking. [br][role silver —][br]Return the underlying `double`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_int64 get_int64]]
|
||
]
|
||
[Return a reference to the underlying `std::int64_t`, without checking. [br][role silver —][br]Return the underlying `std::int64_t`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_object get_object]]
|
||
]
|
||
[Return a reference to the underlying `object`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_string get_string]]
|
||
]
|
||
[Return a reference to the underlying `string`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_uint64 get_uint64]]
|
||
]
|
||
[Return a reference to the underlying `std::uint64_t`, without checking. [br][role silver —][br]Return the underlying `std::uint64_t`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_array if_array]]
|
||
]
|
||
[Return an [link json.ref.boost__json__array `array`] pointer if this is an array, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_bool if_bool]]
|
||
]
|
||
[Return a `bool` pointer if this is a boolean, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_double if_double]]
|
||
]
|
||
[Return a `double` pointer if this is a double, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_int64 if_int64]]
|
||
]
|
||
[Return an `int64_t` pointer if this is a signed integer, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_object if_object]]
|
||
]
|
||
[Return an [link json.ref.boost__json__object `object`] pointer if this is an object, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_string if_string]]
|
||
]
|
||
[Return a [link json.ref.boost__json__string `string`] pointer if this is a string, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_uint64 if_uint64]]
|
||
]
|
||
[Return a `uint64_t` pointer if this is an unsigned integer, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_array is_array]]
|
||
]
|
||
[Return `true` if this is an array.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_bool is_bool]]
|
||
]
|
||
[Return `true` if this is a bool.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_double is_double]]
|
||
]
|
||
[Return `true` if this is a double.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_int64 is_int64]]
|
||
]
|
||
[Return `true` if this is a signed integer.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_null is_null]]
|
||
]
|
||
[Returns true if this is a null.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_number is_number]]
|
||
]
|
||
[Returns true if this is a number.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_object is_object]]
|
||
]
|
||
[Return `true` if this is an object.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_primitive is_primitive]]
|
||
]
|
||
[Returns true if this is not an array or object.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_string is_string]]
|
||
]
|
||
[Return `true` if this is a string.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_structured is_structured]]
|
||
]
|
||
[Returns true if this is an array or object.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_uint64 is_uint64]]
|
||
]
|
||
[Return `true` if this is a unsigned integer.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.kind kind]]
|
||
]
|
||
[Returns the kind of this JSON value.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.operator_eq_ operator=]]
|
||
]
|
||
[Assignment. [br][role silver —][br]Copy assignment. [br][role silver —][br]Move assignment.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.storage storage]]
|
||
]
|
||
[Return the memory resource associated with the value.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.swap swap]]
|
||
]
|
||
[Swap the given values.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.to_number to_number]]
|
||
]
|
||
[Return the stored number cast to an arithmetic type.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.value value]]
|
||
]
|
||
[Default constructor. [br][role silver —][br]Constructor. [br][role silver —][br]Pilfer constructor. [br][role silver —][br]Copy constructor. [br][role silver —][br]Move constructor. [br][role silver —][br]Construct a null. [br][role silver —][br]Construct a bool. [br][role silver —][br]Construct a `std::int64_t`. [br][role silver —][br]Construct a `std::uint64_t`. [br][role silver —][br]Construct a `double`. [br][role silver —][br]Construct a [link json.ref.boost__json__string `string`]. [br][role silver —][br]Construct an [link json.ref.boost__json__array `array`]. [br][role silver —][br]Construct an [link json.ref.boost__json__object `object`]. [br][role silver —][br]Construct from an initializer-list.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value._value ~value] [role silver \[destructor\]]]
|
||
]
|
||
[Destructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Friends]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__value.operator_not__eq_ operator!=]]
|
||
]
|
||
[Return `true` if two values are not equal.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.operator_eq__eq_ operator==]]
|
||
]
|
||
[Return `true` if two values are equal.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.swap swap]]
|
||
]
|
||
[Swap the given values.
|
||
]
|
||
]
|
||
]
|
||
This is a [@https://en.cppreference.com/w/cpp/concepts/regular ['Regular]]. ['Regular] type which works like a variant of the basic JSON data types: array, object, string, number, boolean, and null.
|
||
|
||
[heading Thread Safety]
|
||
|
||
Distinct instances may be accessed concurrently. Non-const member functions of a shared instance may not be called concurrently with any other member functions of that instance.
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:const_reference array::const_reference]
|
||
[indexterm2 const_reference..array]
|
||
|
||
|
||
A const reference to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using const_reference = value const&;
|
||
```
|
||
|
||
[heading Types]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__value.allocator_type allocator_type]]
|
||
]
|
||
[The type of ['Allocator] returned by [link json.ref.boost__json__value.get_allocator `get_allocator`].
|
||
]
|
||
]
|
||
]
|
||
[heading Member Functions]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_array as_array]]
|
||
]
|
||
[Return a reference to the underlying [link json.ref.boost__json__array `array`], or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_bool as_bool]]
|
||
]
|
||
[Return a reference to the underlying `bool`, or throw an exception. [br][role silver —][br]Return the underlying `bool`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_double as_double]]
|
||
]
|
||
[Return a reference to the underlying `double`, or throw an exception. [br][role silver —][br]Return the underlying `double`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_int64 as_int64]]
|
||
]
|
||
[Return a reference to the underlying `std::int64_t`, or throw an exception. [br][role silver —][br]Return the underlying `std::int64_t`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_object as_object]]
|
||
]
|
||
[Return a reference to the underlying `object`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_string as_string]]
|
||
]
|
||
[Return a reference to the underlying `string`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_uint64 as_uint64]]
|
||
]
|
||
[Return a reference to the underlying `std::uint64_t`, or throw an exception. [br][role silver —][br]Return the underlying `std::uint64_t`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.at at]]
|
||
]
|
||
[Access an element, with bounds checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_array emplace_array]]
|
||
]
|
||
[Return a reference to an [link json.ref.boost__json__array `array`], changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_bool emplace_bool]]
|
||
]
|
||
[Return a reference to a `bool`, changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_double emplace_double]]
|
||
]
|
||
[Return a reference to a `double`, changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_int64 emplace_int64]]
|
||
]
|
||
[Return a reference to a `std::int64_t`, changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_null emplace_null]]
|
||
]
|
||
[Change the kind to null, discarding the previous contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_object emplace_object]]
|
||
]
|
||
[Return a reference to an [link json.ref.boost__json__object `object`], changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_string emplace_string]]
|
||
]
|
||
[Return a reference to a [link json.ref.boost__json__string `string`], changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_uint64 emplace_uint64]]
|
||
]
|
||
[Return a reference to a `std::uint64_t`, changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_allocator get_allocator]]
|
||
]
|
||
[Return the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_array get_array]]
|
||
]
|
||
[Return a reference to the underlying `array`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_bool get_bool]]
|
||
]
|
||
[Return a reference to the underlying `bool`, without checking. [br][role silver —][br]Return the underlying `bool`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_double get_double]]
|
||
]
|
||
[Return a reference to the underlying `double`, without checking. [br][role silver —][br]Return the underlying `double`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_int64 get_int64]]
|
||
]
|
||
[Return a reference to the underlying `std::int64_t`, without checking. [br][role silver —][br]Return the underlying `std::int64_t`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_object get_object]]
|
||
]
|
||
[Return a reference to the underlying `object`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_string get_string]]
|
||
]
|
||
[Return a reference to the underlying `string`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_uint64 get_uint64]]
|
||
]
|
||
[Return a reference to the underlying `std::uint64_t`, without checking. [br][role silver —][br]Return the underlying `std::uint64_t`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_array if_array]]
|
||
]
|
||
[Return an [link json.ref.boost__json__array `array`] pointer if this is an array, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_bool if_bool]]
|
||
]
|
||
[Return a `bool` pointer if this is a boolean, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_double if_double]]
|
||
]
|
||
[Return a `double` pointer if this is a double, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_int64 if_int64]]
|
||
]
|
||
[Return an `int64_t` pointer if this is a signed integer, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_object if_object]]
|
||
]
|
||
[Return an [link json.ref.boost__json__object `object`] pointer if this is an object, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_string if_string]]
|
||
]
|
||
[Return a [link json.ref.boost__json__string `string`] pointer if this is a string, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_uint64 if_uint64]]
|
||
]
|
||
[Return a `uint64_t` pointer if this is an unsigned integer, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_array is_array]]
|
||
]
|
||
[Return `true` if this is an array.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_bool is_bool]]
|
||
]
|
||
[Return `true` if this is a bool.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_double is_double]]
|
||
]
|
||
[Return `true` if this is a double.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_int64 is_int64]]
|
||
]
|
||
[Return `true` if this is a signed integer.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_null is_null]]
|
||
]
|
||
[Returns true if this is a null.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_number is_number]]
|
||
]
|
||
[Returns true if this is a number.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_object is_object]]
|
||
]
|
||
[Return `true` if this is an object.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_primitive is_primitive]]
|
||
]
|
||
[Returns true if this is not an array or object.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_string is_string]]
|
||
]
|
||
[Return `true` if this is a string.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_structured is_structured]]
|
||
]
|
||
[Returns true if this is an array or object.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_uint64 is_uint64]]
|
||
]
|
||
[Return `true` if this is a unsigned integer.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.kind kind]]
|
||
]
|
||
[Returns the kind of this JSON value.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.operator_eq_ operator=]]
|
||
]
|
||
[Assignment. [br][role silver —][br]Copy assignment. [br][role silver —][br]Move assignment.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.storage storage]]
|
||
]
|
||
[Return the memory resource associated with the value.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.swap swap]]
|
||
]
|
||
[Swap the given values.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.to_number to_number]]
|
||
]
|
||
[Return the stored number cast to an arithmetic type.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.value value]]
|
||
]
|
||
[Default constructor. [br][role silver —][br]Constructor. [br][role silver —][br]Pilfer constructor. [br][role silver —][br]Copy constructor. [br][role silver —][br]Move constructor. [br][role silver —][br]Construct a null. [br][role silver —][br]Construct a bool. [br][role silver —][br]Construct a `std::int64_t`. [br][role silver —][br]Construct a `std::uint64_t`. [br][role silver —][br]Construct a `double`. [br][role silver —][br]Construct a [link json.ref.boost__json__string `string`]. [br][role silver —][br]Construct an [link json.ref.boost__json__array `array`]. [br][role silver —][br]Construct an [link json.ref.boost__json__object `object`]. [br][role silver —][br]Construct from an initializer-list.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value._value ~value] [role silver \[destructor\]]]
|
||
]
|
||
[Destructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Friends]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__value.operator_not__eq_ operator!=]]
|
||
]
|
||
[Return `true` if two values are not equal.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.operator_eq__eq_ operator==]]
|
||
]
|
||
[Return `true` if two values are equal.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.swap swap]]
|
||
]
|
||
[Swap the given values.
|
||
]
|
||
]
|
||
]
|
||
This is a [@https://en.cppreference.com/w/cpp/concepts/regular ['Regular]]. ['Regular] type which works like a variant of the basic JSON data types: array, object, string, number, boolean, and null.
|
||
|
||
[heading Thread Safety]
|
||
|
||
Distinct instances may be accessed concurrently. Non-const member functions of a shared instance may not be called concurrently with any other member functions of that instance.
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:pointer array::pointer]
|
||
[indexterm2 pointer..array]
|
||
|
||
|
||
A pointer to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using pointer = value*;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:const_pointer array::const_pointer]
|
||
[indexterm2 const_pointer..array]
|
||
|
||
|
||
A const pointer to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using const_pointer = value const*;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:iterator array::iterator]
|
||
[indexterm2 iterator..array]
|
||
|
||
|
||
A random access iterator to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using iterator = value*;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:const_iterator array::const_iterator]
|
||
[indexterm2 const_iterator..array]
|
||
|
||
|
||
A random access const iterator to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using const_iterator = value const*;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:reverse_iterator array::reverse_iterator]
|
||
[indexterm2 reverse_iterator..array]
|
||
|
||
|
||
A reverse random access iterator to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using reverse_iterator = std::reverse_iterator< iterator >;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:const_reverse_iterator array::const_reverse_iterator]
|
||
[indexterm2 const_reverse_iterator..array]
|
||
|
||
|
||
A reverse random access const iterator to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using const_reverse_iterator = std::reverse_iterator< const_iterator >;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:swap array::swap]
|
||
[indexterm2 swap..array]
|
||
|
||
|
||
Exchange the given values.
|
||
```
|
||
friend void
|
||
``[link json.ref.boost__json__array.swap.overload1 swap]``(
|
||
array& lhs,
|
||
array& rhs);
|
||
``[''''»''' [link json.ref.boost__json__array.swap.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Swap the contents.
|
||
```
|
||
void
|
||
``[link json.ref.boost__json__array.swap.overload2 swap]``(
|
||
array& other);
|
||
``[''''»''' [link json.ref.boost__json__array.swap.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 array::swap (1 of 2 overloads)]
|
||
|
||
Exchange the given values.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/array.hpp]
|
||
|
||
```
|
||
friend void
|
||
swap(
|
||
array& lhs,
|
||
array& rhs);
|
||
```
|
||
|
||
[heading Description]
|
||
Exchanges the contents of the array `lhs` with another array `rhs`. Ownership of the respective [link json.ref.boost__json__memory_resource `memory_resource`] objects is not transferred.
|
||
|
||
* If `*lhs.storage() == *rhs.storage()`, ownership of the underlying memory is swapped in constant time, with no possibility of exceptions. All iterators and references remain valid.
|
||
|
||
* If `*lhs.storage() != *rhs.storage()`, the contents are logically swapped by making a copy, which can throw. In this case all iterators and references are invalidated.
|
||
|
||
[heading Effects]
|
||
|
||
```
|
||
lhs.swap( rhs );
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant or linear in `lhs.size() + rhs.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`lhs`
|
||
]
|
||
[
|
||
The array to exchange.
|
||
]
|
||
]
|
||
[
|
||
[`rhs`
|
||
]
|
||
[
|
||
The array to exchange. If `&lhs == &rhs`, this function call has no effect.
|
||
]
|
||
]
|
||
]
|
||
[heading See Also]
|
||
[link json.ref.boost__json__array.swap `array::swap`]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 array::swap (2 of 2 overloads)]
|
||
|
||
Swap the contents.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
swap(
|
||
array& other);
|
||
```
|
||
|
||
[heading Description]
|
||
Exchanges the contents of this array with another array. Ownership of the respective [link json.ref.boost__json__memory_resource `memory_resource`] objects is not transferred.
|
||
|
||
* If `*other.storage() == *this->storage()`, ownership of the underlying memory is swapped in constant time, with no possibility of exceptions. All iterators and references remain valid.
|
||
|
||
* If `*other.storage() != *this->storage()`, the contents are logically swapped by making copies, which can throw. In this case all iterators and references are invalidated.
|
||
|
||
[heading Complexity]
|
||
Constant or linear in [link json.ref.boost__json__array.size `size()`] plus `other.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The value to swap with. If `this == &other`, this function call has no effect.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:operator_eq__eq_ array::operator==]
|
||
[indexterm2 operator==..array]
|
||
|
||
|
||
Return `true` if two arrays are equal.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/array.hpp]
|
||
|
||
```
|
||
friend bool
|
||
operator==(
|
||
array const& lhs,
|
||
array const& rhs);
|
||
```
|
||
|
||
[heading Description]
|
||
Arrays are equal when their sizes are the same, and they are element-for-element equal in order.
|
||
|
||
[heading Effects]
|
||
`return std::equal( lhs.begin(), lhs.end(), rhs.begin(), rhs.end() );`
|
||
[heading Complexity]
|
||
Constant or linear in `lhs.size()`.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:operator_not__eq_ array::operator!=]
|
||
[indexterm2 operator!=..array]
|
||
|
||
|
||
Return `true` if two arrays are not equal.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/array.hpp]
|
||
|
||
```
|
||
friend bool
|
||
operator!=(
|
||
array const& lhs,
|
||
array const& rhs);
|
||
```
|
||
|
||
[heading Description]
|
||
Arrays are equal when their sizes are the same, and they are element-for-element equal in order.
|
||
|
||
[heading Effects]
|
||
`return ! std::equal( lhs.begin(), lhs.end(), rhs.begin(), rhs.end() );`
|
||
[heading Complexity]
|
||
Constant or linear in `lhs.size()`.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:_array array::~array]
|
||
[indexterm2 ~array..array]
|
||
|
||
|
||
Destructor.
|
||
[heading Synopsis]
|
||
```
|
||
~array();
|
||
```
|
||
|
||
[heading Description]
|
||
The destructor for each element is called if needed, any used memory is deallocated, and shared ownership of the [link json.ref.boost__json__memory_resource `memory_resource`] is released.
|
||
|
||
[heading Complexity]
|
||
Constant, or linear in [link json.ref.boost__json__array.size `size()`].
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:array array::array]
|
||
[indexterm2 array..array]
|
||
|
||
|
||
Constructor.
|
||
```
|
||
``[link json.ref.boost__json__array.array.overload1 array]``();
|
||
``[''''»''' [link json.ref.boost__json__array.array.overload1 `more...`]]``
|
||
|
||
explicit
|
||
``[link json.ref.boost__json__array.array.overload2 array]``(
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__array.array.overload2 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__array.array.overload3 array]``(
|
||
std::size_t count,
|
||
value const& v,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__array.array.overload3 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__array.array.overload4 array]``(
|
||
std::size_t count,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__array.array.overload4 `more...`]]``
|
||
|
||
template<
|
||
class InputIt>
|
||
``[link json.ref.boost__json__array.array.overload5 array]``(
|
||
InputIt first,
|
||
InputIt last,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__array.array.overload5 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__array.array.overload11 array]``(
|
||
std::initializer_list< value_ref > init,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__array.array.overload11 `more...`]]``
|
||
```
|
||
|
||
|
||
Copy constructor.
|
||
```
|
||
``[link json.ref.boost__json__array.array.overload6 array]``(
|
||
array const& other);
|
||
``[''''»''' [link json.ref.boost__json__array.array.overload6 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__array.array.overload7 array]``(
|
||
array const& other,
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__array.array.overload7 `more...`]]``
|
||
```
|
||
|
||
|
||
Pilfer constructor.
|
||
```
|
||
``[link json.ref.boost__json__array.array.overload8 array]``(
|
||
pilfered< array > other);
|
||
``[''''»''' [link json.ref.boost__json__array.array.overload8 `more...`]]``
|
||
```
|
||
|
||
|
||
Move constructor.
|
||
```
|
||
``[link json.ref.boost__json__array.array.overload9 array]``(
|
||
array&& other);
|
||
``[''''»''' [link json.ref.boost__json__array.array.overload9 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__array.array.overload10 array]``(
|
||
array&& other,
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__array.array.overload10 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 array::array (1 of 11 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
array();
|
||
```
|
||
|
||
[heading Description]
|
||
The constructed array is empty with zero capacity, using the default memory resource.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 array::array (2 of 11 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
array(
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
The constructed array is empty with zero capacity, using the specified memory resource.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 array::array (3 of 11 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
array(
|
||
std::size_t count,
|
||
value const& v,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
The array is constructed with `count` copies of the value `v`, using the specified memory resource.
|
||
|
||
[heading Complexity]
|
||
Linear in `count`
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`count`
|
||
]
|
||
[
|
||
The number of copies to insert.
|
||
]
|
||
]
|
||
[
|
||
[`v`
|
||
]
|
||
[
|
||
The value to be inserted.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 array::array (4 of 11 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
array(
|
||
std::size_t count,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
The array is constructed with `count` null values, using the specified memory resource.
|
||
|
||
[heading Complexity]
|
||
Linear in `count`
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`count`
|
||
]
|
||
[
|
||
The number of nulls to insert.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload5 array::array (5 of 11 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class InputIt>
|
||
array(
|
||
InputIt first,
|
||
InputIt last,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
The array is constructed with the elements in the range `{first, last)`, preserving order, using the specified memory resource.
|
||
|
||
[heading Constraints]
|
||
|
||
```
|
||
std::is_constructible_v<value, std::iterator_traits<InputIt>::value_type>
|
||
```
|
||
|
||
|
||
[heading Complexity]
|
||
Linear in `std::distance(first, last)`
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`first`
|
||
]
|
||
[
|
||
An input iterator pointing to the first element to insert, or pointing to the end of the range.
|
||
]
|
||
]
|
||
[
|
||
[`last`
|
||
]
|
||
[
|
||
An input iterator pointing to the end of the range.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
[heading Template Parameters]
|
||
[table [[Type][Description]]
|
||
[
|
||
[`InputIt`
|
||
]
|
||
[
|
||
a type satisfying the requirements of [*InputIterator].
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload6 array::array (6 of 11 overloads)]
|
||
|
||
Copy constructor.
|
||
[heading Synopsis]
|
||
```
|
||
array(
|
||
array const& other);
|
||
```
|
||
|
||
[heading Description]
|
||
The array is constructed with a copy of the contents of `other`, using `other`'s memory resource.
|
||
|
||
[heading Complexity]
|
||
Linear in `other.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The array to copy
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload7 array::array (7 of 11 overloads)]
|
||
|
||
Copy constructor.
|
||
[heading Synopsis]
|
||
```
|
||
array(
|
||
array const& other,
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
The array is constructed with a copy of the contents of `other`, using the specified memory resource.
|
||
|
||
[heading Complexity]
|
||
Linear in `other.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The array to copy
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload8 array::array (8 of 11 overloads)]
|
||
|
||
Pilfer constructor.
|
||
[heading Synopsis]
|
||
```
|
||
array(
|
||
pilfered< array > other);
|
||
```
|
||
|
||
[heading Description]
|
||
The array is constructed by acquiring ownership of the contents of `other` using pilfer semantics. This is more efficient than move construction, when it is known that the moved-from object will be immediately destroyed afterwards.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The value to pilfer. After pilfer construction, `other` is not in a usable state and may only be destroyed.
|
||
]
|
||
]
|
||
]
|
||
[heading See Also]
|
||
[link json.ref.boost__json__pilfer `pilfer`], [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0308r0.html Valueless Variants Considered Harmful]
|
||
|
||
[endsect]
|
||
|
||
[section:overload9 array::array (9 of 11 overloads)]
|
||
|
||
Move constructor.
|
||
[heading Synopsis]
|
||
```
|
||
array(
|
||
array&& other);
|
||
```
|
||
|
||
[heading Description]
|
||
The array is constructed by acquiring ownership of the contents of `other` and shared ownership of `other`'s memory resource.
|
||
|
||
[heading Remarks]
|
||
|
||
After construction, the moved-from array behaves as if newly constructed with its current storage pointer.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The container to move
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload10 array::array (10 of 11 overloads)]
|
||
|
||
Move constructor.
|
||
[heading Synopsis]
|
||
```
|
||
array(
|
||
array&& other,
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
The array is constructed with the contents of `other` by move semantics, using the specified memory resource:
|
||
|
||
* If `*other.storage() == *sp`, ownership of the underlying memory is transferred in constant time, with no possibility of exceptions. After construction, the moved-from array behaves as if newly constructed with its current storage pointer.
|
||
|
||
* If `*other.storage() != *sp`, an element-wise copy is performed, which may throw. In this case, the moved-from array is not changed.
|
||
|
||
[heading Complexity]
|
||
At most, linear in `other.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The container to move
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload11 array::array (11 of 11 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
array(
|
||
std::initializer_list< value_ref > init,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
The array is constructed with a copy of the values in the initializer-list in order, using the specified memory resource.
|
||
|
||
[heading Complexity]
|
||
Linear in `init.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`init`
|
||
]
|
||
[
|
||
The initializer list to insert
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:operator_eq_ array::operator=]
|
||
[indexterm2 operator=..array]
|
||
|
||
|
||
Copy assignment.
|
||
```
|
||
array&
|
||
``[link json.ref.boost__json__array.operator_eq_.overload1 operator=]``(
|
||
array const& other);
|
||
``[''''»''' [link json.ref.boost__json__array.operator_eq_.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Move assignment.
|
||
```
|
||
array&
|
||
``[link json.ref.boost__json__array.operator_eq_.overload2 operator=]``(
|
||
array&& other);
|
||
``[''''»''' [link json.ref.boost__json__array.operator_eq_.overload2 `more...`]]``
|
||
```
|
||
|
||
|
||
Assignment.
|
||
```
|
||
array&
|
||
``[link json.ref.boost__json__array.operator_eq_.overload3 operator=]``(
|
||
std::initializer_list< value_ref > init);
|
||
``[''''»''' [link json.ref.boost__json__array.operator_eq_.overload3 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 array::operator= (1 of 3 overloads)]
|
||
|
||
Copy assignment.
|
||
[heading Synopsis]
|
||
```
|
||
array&
|
||
operator=(
|
||
array const& other);
|
||
```
|
||
|
||
[heading Description]
|
||
The contents of the array are replaced with an element-wise copy of `other`.
|
||
|
||
[heading Complexity]
|
||
Linear in [link json.ref.boost__json__array.size `size()`] plus `other.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The array to copy.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 array::operator= (2 of 3 overloads)]
|
||
|
||
Move assignment.
|
||
[heading Synopsis]
|
||
```
|
||
array&
|
||
operator=(
|
||
array&& other);
|
||
```
|
||
|
||
[heading Description]
|
||
The contents of the array are replaced with the contents of `other` using move semantics:
|
||
|
||
* If `*other.storage() == *sp`, ownership of the underlying memory is transferred in constant time, with no possibility of exceptions. After assignment, the moved-from array behaves as if newly constructed with its current storage pointer.
|
||
|
||
* If `*other.storage() != *sp`, an element-wise copy is performed, which may throw. In this case, the moved-from array is not changed.
|
||
|
||
[heading Complexity]
|
||
Constant, or linear in `this->size()` plus `other.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The array to move.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 array::operator= (3 of 3 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
array&
|
||
operator=(
|
||
std::initializer_list< value_ref > init);
|
||
```
|
||
|
||
[heading Description]
|
||
The contents of the array are replaced with a copy of the values in the initializer-list.
|
||
|
||
[heading Complexity]
|
||
Linear in `this->size()` plus `init.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`init`
|
||
]
|
||
[
|
||
The initializer list to copy.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:storage array::storage]
|
||
[indexterm2 storage..array]
|
||
|
||
|
||
Return the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
[heading Synopsis]
|
||
```
|
||
storage_ptr const&
|
||
storage() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This returns the [link json.ref.boost__json__memory_resource `memory_resource`] used by the container.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:get_allocator array::get_allocator]
|
||
[indexterm2 get_allocator..array]
|
||
|
||
|
||
Return the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
[heading Synopsis]
|
||
```
|
||
allocator_type
|
||
get_allocator() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns an instance of [link json.ref.boost__json__polymorphic_allocator `polymorphic_allocator`] constructed from the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:at array::at]
|
||
[indexterm2 at..array]
|
||
|
||
|
||
Access an element, with bounds checking.
|
||
```
|
||
value&
|
||
``[link json.ref.boost__json__array.at.overload1 at]``(
|
||
std::size_t pos);
|
||
``[''''»''' [link json.ref.boost__json__array.at.overload1 `more...`]]``
|
||
|
||
value const&
|
||
``[link json.ref.boost__json__array.at.overload2 at]``(
|
||
std::size_t pos) const;
|
||
``[''''»''' [link json.ref.boost__json__array.at.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 array::at (1 of 2 overloads)]
|
||
|
||
Access an element, with bounds checking.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
at(
|
||
std::size_t pos);
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a reference to the element specified at location `pos`, with bounds checking. If `pos` is not within the range of the container, an exception of type `std::out_of_range` is thrown.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
A zero-based index.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::out_of_range`
|
||
]
|
||
[
|
||
`pos >= size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 array::at (2 of 2 overloads)]
|
||
|
||
Access an element, with bounds checking.
|
||
[heading Synopsis]
|
||
```
|
||
value const&
|
||
at(
|
||
std::size_t pos) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a reference to the element specified at location `pos`, with bounds checking. If `pos` is not within the range of the container, an exception of type `std::out_of_range` is thrown.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
A zero-based index.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::out_of_range`
|
||
]
|
||
[
|
||
`pos >= size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:operator_lb__rb_ array::operator\[\]]
|
||
[indexterm2 operator\[\]..array]
|
||
|
||
|
||
Access an element.
|
||
```
|
||
value&
|
||
``[link json.ref.boost__json__array.operator_lb__rb_.overload1 operator\[\]]``(
|
||
std::size_t pos);
|
||
``[''''»''' [link json.ref.boost__json__array.operator_lb__rb_.overload1 `more...`]]``
|
||
|
||
value const&
|
||
``[link json.ref.boost__json__array.operator_lb__rb_.overload2 operator\[\]]``(
|
||
std::size_t pos) const;
|
||
``[''''»''' [link json.ref.boost__json__array.operator_lb__rb_.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 array::operator\[\] (1 of 2 overloads)]
|
||
|
||
Access an element.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator\[\](
|
||
std::size_t pos);
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a reference to the element specified at location `pos`. No bounds checking is performed.
|
||
|
||
[heading Precondition]
|
||
`pos < size()`
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
A zero-based index
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 array::operator\[\] (2 of 2 overloads)]
|
||
|
||
Access an element.
|
||
[heading Synopsis]
|
||
```
|
||
value const&
|
||
operator\[\](
|
||
std::size_t pos) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a reference to the element specified at location `pos`. No bounds checking is performed.
|
||
|
||
[heading Precondition]
|
||
`pos < size()`
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
A zero-based index
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:front array::front]
|
||
[indexterm2 front..array]
|
||
|
||
|
||
Access the first element.
|
||
```
|
||
value&
|
||
``[link json.ref.boost__json__array.front.overload1 front]``();
|
||
``[''''»''' [link json.ref.boost__json__array.front.overload1 `more...`]]``
|
||
|
||
value const&
|
||
``[link json.ref.boost__json__array.front.overload2 front]``() const;
|
||
``[''''»''' [link json.ref.boost__json__array.front.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 array::front (1 of 2 overloads)]
|
||
|
||
Access the first element.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
front();
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a reference to the first element.
|
||
|
||
[heading Precondition]
|
||
`not empty()`
|
||
[heading Complexity]
|
||
Constant.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 array::front (2 of 2 overloads)]
|
||
|
||
Access the first element.
|
||
[heading Synopsis]
|
||
```
|
||
value const&
|
||
front() const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a reference to the first element.
|
||
|
||
[heading Precondition]
|
||
`not empty()`
|
||
[heading Complexity]
|
||
Constant.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:back array::back]
|
||
[indexterm2 back..array]
|
||
|
||
|
||
Access the last element.
|
||
```
|
||
value&
|
||
``[link json.ref.boost__json__array.back.overload1 back]``();
|
||
``[''''»''' [link json.ref.boost__json__array.back.overload1 `more...`]]``
|
||
|
||
value const&
|
||
``[link json.ref.boost__json__array.back.overload2 back]``() const;
|
||
``[''''»''' [link json.ref.boost__json__array.back.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 array::back (1 of 2 overloads)]
|
||
|
||
Access the last element.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
back();
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a reference to the last element.
|
||
|
||
[heading Precondition]
|
||
`not empty()`
|
||
[heading Complexity]
|
||
Constant.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 array::back (2 of 2 overloads)]
|
||
|
||
Access the last element.
|
||
[heading Synopsis]
|
||
```
|
||
value const&
|
||
back() const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a reference to the last element.
|
||
|
||
[heading Precondition]
|
||
`not empty()`
|
||
[heading Complexity]
|
||
Constant.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:data array::data]
|
||
[indexterm2 data..array]
|
||
|
||
|
||
Access the underlying array directly.
|
||
```
|
||
value*
|
||
``[link json.ref.boost__json__array.data.overload1 data]``();
|
||
``[''''»''' [link json.ref.boost__json__array.data.overload1 `more...`]]``
|
||
|
||
value const*
|
||
``[link json.ref.boost__json__array.data.overload2 data]``() const;
|
||
``[''''»''' [link json.ref.boost__json__array.data.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 array::data (1 of 2 overloads)]
|
||
|
||
Access the underlying array directly.
|
||
[heading Synopsis]
|
||
```
|
||
value*
|
||
data();
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a pointer to the underlying array serving as element storage. The value returned is such that the range `{data(), data() + size())` is always a valid range, even if the container is empty.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Remarks]
|
||
|
||
If `size() == 0`, the function may or may not return a null pointer.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 array::data (2 of 2 overloads)]
|
||
|
||
Access the underlying array directly.
|
||
[heading Synopsis]
|
||
```
|
||
value const*
|
||
data() const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a pointer to the underlying array serving as element storage. The value returned is such that the range `{data(), data() + size())` is always a valid range, even if the container is empty.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Remarks]
|
||
|
||
If `size() == 0`, the function may or may not return a null pointer.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:if_contains array::if_contains]
|
||
[indexterm2 if_contains..array]
|
||
|
||
|
||
Return a pointer to an element, or nullptr if the index is invalid.
|
||
```
|
||
value const*
|
||
``[link json.ref.boost__json__array.if_contains.overload1 if_contains]``(
|
||
std::size_t pos) const;
|
||
``[''''»''' [link json.ref.boost__json__array.if_contains.overload1 `more...`]]``
|
||
|
||
value*
|
||
``[link json.ref.boost__json__array.if_contains.overload2 if_contains]``(
|
||
std::size_t pos);
|
||
``[''''»''' [link json.ref.boost__json__array.if_contains.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 array::if_contains (1 of 2 overloads)]
|
||
|
||
Return a pointer to an element, or nullptr if the index is invalid.
|
||
[heading Synopsis]
|
||
```
|
||
value const*
|
||
if_contains(
|
||
std::size_t pos) const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns a pointer to the element at index `pos` when the index is less then the size of the container. Otherwise it returns null.
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
if( auto p = arr.if_contains( 1 ) )
|
||
std::cout << *p;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index of the element to return.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 array::if_contains (2 of 2 overloads)]
|
||
|
||
Return a pointer to an element, or nullptr if the index is invalid.
|
||
[heading Synopsis]
|
||
```
|
||
value*
|
||
if_contains(
|
||
std::size_t pos);
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns a pointer to the element at index `pos` when the index is less then the size of the container. Otherwise it returns null.
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
if( auto p = arr.if_contains( 1 ) )
|
||
std::cout << *p;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index of the element to return.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:begin array::begin]
|
||
[indexterm2 begin..array]
|
||
|
||
|
||
Return an iterator to the first element.
|
||
```
|
||
iterator
|
||
``[link json.ref.boost__json__array.begin.overload1 begin]``();
|
||
``[''''»''' [link json.ref.boost__json__array.begin.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Return a const iterator to the first element.
|
||
```
|
||
const_iterator
|
||
``[link json.ref.boost__json__array.begin.overload2 begin]``() const;
|
||
``[''''»''' [link json.ref.boost__json__array.begin.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 array::begin (1 of 2 overloads)]
|
||
|
||
Return an iterator to the first element.
|
||
[heading Synopsis]
|
||
```
|
||
iterator
|
||
begin();
|
||
```
|
||
|
||
[heading Description]
|
||
If the container is empty, [link json.ref.boost__json__array.end `end()`] is returned.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 array::begin (2 of 2 overloads)]
|
||
|
||
Return a const iterator to the first element.
|
||
[heading Synopsis]
|
||
```
|
||
const_iterator
|
||
begin() const;
|
||
```
|
||
|
||
[heading Description]
|
||
If the container is empty, [link json.ref.boost__json__array.end `end()`] is returned.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:cbegin array::cbegin]
|
||
[indexterm2 cbegin..array]
|
||
|
||
|
||
Return a const iterator to the first element.
|
||
[heading Synopsis]
|
||
```
|
||
const_iterator
|
||
cbegin() const;
|
||
```
|
||
|
||
[heading Description]
|
||
If the container is empty, [link json.ref.boost__json__array.cend `cend()`] is returned.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:end array::end]
|
||
[indexterm2 end..array]
|
||
|
||
|
||
Return an iterator to the element following the last element.
|
||
```
|
||
iterator
|
||
``[link json.ref.boost__json__array.end.overload1 end]``();
|
||
``[''''»''' [link json.ref.boost__json__array.end.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Return a const iterator to the element following the last element.
|
||
```
|
||
const_iterator
|
||
``[link json.ref.boost__json__array.end.overload2 end]``() const;
|
||
``[''''»''' [link json.ref.boost__json__array.end.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 array::end (1 of 2 overloads)]
|
||
|
||
Return an iterator to the element following the last element.
|
||
[heading Synopsis]
|
||
```
|
||
iterator
|
||
end();
|
||
```
|
||
|
||
[heading Description]
|
||
The element acts as a placeholder; attempting to access it results in undefined behavior.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 array::end (2 of 2 overloads)]
|
||
|
||
Return a const iterator to the element following the last element.
|
||
[heading Synopsis]
|
||
```
|
||
const_iterator
|
||
end() const;
|
||
```
|
||
|
||
[heading Description]
|
||
The element acts as a placeholder; attempting to access it results in undefined behavior.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:cend array::cend]
|
||
[indexterm2 cend..array]
|
||
|
||
|
||
Return a const iterator to the element following the last element.
|
||
[heading Synopsis]
|
||
```
|
||
const_iterator
|
||
cend() const;
|
||
```
|
||
|
||
[heading Description]
|
||
The element acts as a placeholder; attempting to access it results in undefined behavior.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:rbegin array::rbegin]
|
||
[indexterm2 rbegin..array]
|
||
|
||
|
||
Return a reverse iterator to the first element of the reversed container.
|
||
```
|
||
reverse_iterator
|
||
``[link json.ref.boost__json__array.rbegin.overload1 rbegin]``();
|
||
``[''''»''' [link json.ref.boost__json__array.rbegin.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Return a const reverse iterator to the first element of the reversed container.
|
||
```
|
||
const_reverse_iterator
|
||
``[link json.ref.boost__json__array.rbegin.overload2 rbegin]``() const;
|
||
``[''''»''' [link json.ref.boost__json__array.rbegin.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 array::rbegin (1 of 2 overloads)]
|
||
|
||
Return a reverse iterator to the first element of the reversed container.
|
||
[heading Synopsis]
|
||
```
|
||
reverse_iterator
|
||
rbegin();
|
||
```
|
||
|
||
[heading Description]
|
||
The pointed-to element corresponds to the last element of the non-reversed container. If the container is empty, [link json.ref.boost__json__array.rend `rend()`] is returned.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 array::rbegin (2 of 2 overloads)]
|
||
|
||
Return a const reverse iterator to the first element of the reversed container.
|
||
[heading Synopsis]
|
||
```
|
||
const_reverse_iterator
|
||
rbegin() const;
|
||
```
|
||
|
||
[heading Description]
|
||
The pointed-to element corresponds to the last element of the non-reversed container. If the container is empty, [link json.ref.boost__json__array.rend `rend()`] is returned.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:crbegin array::crbegin]
|
||
[indexterm2 crbegin..array]
|
||
|
||
|
||
Return a const reverse iterator to the first element of the reversed container.
|
||
[heading Synopsis]
|
||
```
|
||
const_reverse_iterator
|
||
crbegin() const;
|
||
```
|
||
|
||
[heading Description]
|
||
The pointed-to element corresponds to the last element of the non-reversed container. If the container is empty, [link json.ref.boost__json__array.crend `crend()`] is returned.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:rend array::rend]
|
||
[indexterm2 rend..array]
|
||
|
||
|
||
Return a reverse iterator to the element following the last element of the reversed container.
|
||
```
|
||
reverse_iterator
|
||
``[link json.ref.boost__json__array.rend.overload1 rend]``();
|
||
``[''''»''' [link json.ref.boost__json__array.rend.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Return a const reverse iterator to the element following the last element of the reversed container.
|
||
```
|
||
const_reverse_iterator
|
||
``[link json.ref.boost__json__array.rend.overload2 rend]``() const;
|
||
``[''''»''' [link json.ref.boost__json__array.rend.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 array::rend (1 of 2 overloads)]
|
||
|
||
Return a reverse iterator to the element following the last element of the reversed container.
|
||
[heading Synopsis]
|
||
```
|
||
reverse_iterator
|
||
rend();
|
||
```
|
||
|
||
[heading Description]
|
||
The pointed-to element corresponds to the element preceding the first element of the non-reversed container. The element acts as a placeholder; attempting to access it results in undefined behavior.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 array::rend (2 of 2 overloads)]
|
||
|
||
Return a const reverse iterator to the element following the last element of the reversed container.
|
||
[heading Synopsis]
|
||
```
|
||
const_reverse_iterator
|
||
rend() const;
|
||
```
|
||
|
||
[heading Description]
|
||
The pointed-to element corresponds to the element preceding the first element of the non-reversed container. The element acts as a placeholder; attempting to access it results in undefined behavior.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:crend array::crend]
|
||
[indexterm2 crend..array]
|
||
|
||
|
||
Return a const reverse iterator to the element following the last element of the reversed container.
|
||
[heading Synopsis]
|
||
```
|
||
const_reverse_iterator
|
||
crend() const;
|
||
```
|
||
|
||
[heading Description]
|
||
The pointed-to element corresponds to the element preceding the first element of the non-reversed container. The element acts as a placeholder; attempting to access it results in undefined behavior.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:size array::size]
|
||
[indexterm2 size..array]
|
||
|
||
|
||
Return the number of elements in the array.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
size() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This returns the number of elements in the array. The value returned may be different from the number returned from [link json.ref.boost__json__array.capacity `capacity`].
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:capacity array::capacity]
|
||
[indexterm2 capacity..array]
|
||
|
||
|
||
Return the number of elements that can be held in currently allocated memory.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
capacity() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This number may be larger than the value returned by [link json.ref.boost__json__array.size `size()`].
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:empty array::empty]
|
||
[indexterm2 empty..array]
|
||
|
||
|
||
Check if the array has no elements.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
empty() const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns `true` if there are no elements in the array, i.e. [link json.ref.boost__json__array.size `size()`] returns 0.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:reserve array::reserve]
|
||
[indexterm2 reserve..array]
|
||
|
||
|
||
Increase the capacity to at least a certain amount.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
reserve(
|
||
std::size_t new_capacity);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This increases the [link json.ref.boost__json__array.capacity `capacity()`] to a value that is greater than or equal to `new_capacity`. If `new_capacity > capacity()`, new memory is allocated. Otherwise, the call has no effect. The number of elements and therefore the [link json.ref.boost__json__array.size `size()`] of the container is not changed.
|
||
|
||
|
||
If new memory is allocated, all iterators including any past-the-end iterators, and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated.
|
||
|
||
[heading Complexity]
|
||
At most, linear in [link json.ref.boost__json__array.size `size()`].
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`new_capacity`
|
||
]
|
||
[
|
||
The new capacity of the array.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`new_capacity > max_size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:shrink_to_fit array::shrink_to_fit]
|
||
[indexterm2 shrink_to_fit..array]
|
||
|
||
|
||
Request the removal of unused capacity.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
shrink_to_fit();
|
||
```
|
||
|
||
[heading Description]
|
||
This performs a non-binding request to reduce the capacity to the current size. The request may or may not be fulfilled. If reallocation occurs, all iterators including any past-the-end iterators, and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated.
|
||
|
||
[heading Complexity]
|
||
At most, linear in [link json.ref.boost__json__array.size `size()`].
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:clear array::clear]
|
||
[indexterm2 clear..array]
|
||
|
||
|
||
Clear the contents.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
clear();
|
||
```
|
||
|
||
[heading Description]
|
||
Erases all elements from the container. After this call, [link json.ref.boost__json__array.size `size()`] returns zero but [link json.ref.boost__json__array.capacity `capacity()`] is unchanged. All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated.
|
||
|
||
[heading Complexity]
|
||
Linear in [link json.ref.boost__json__array.size `size()`].
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:insert array::insert]
|
||
[indexterm2 insert..array]
|
||
|
||
|
||
Insert elements before the specified location.
|
||
```
|
||
iterator
|
||
``[link json.ref.boost__json__array.insert.overload1 insert]``(
|
||
const_iterator pos,
|
||
value const& v);
|
||
``[''''»''' [link json.ref.boost__json__array.insert.overload1 `more...`]]``
|
||
|
||
iterator
|
||
``[link json.ref.boost__json__array.insert.overload2 insert]``(
|
||
const_iterator pos,
|
||
value&& v);
|
||
``[''''»''' [link json.ref.boost__json__array.insert.overload2 `more...`]]``
|
||
|
||
iterator
|
||
``[link json.ref.boost__json__array.insert.overload3 insert]``(
|
||
const_iterator pos,
|
||
std::size_t count,
|
||
value const& v);
|
||
``[''''»''' [link json.ref.boost__json__array.insert.overload3 `more...`]]``
|
||
|
||
template<
|
||
class InputIt>
|
||
iterator
|
||
``[link json.ref.boost__json__array.insert.overload4 insert]``(
|
||
const_iterator pos,
|
||
InputIt first,
|
||
InputIt last);
|
||
``[''''»''' [link json.ref.boost__json__array.insert.overload4 `more...`]]``
|
||
|
||
iterator
|
||
``[link json.ref.boost__json__array.insert.overload5 insert]``(
|
||
const_iterator pos,
|
||
std::initializer_list< value_ref > init);
|
||
``[''''»''' [link json.ref.boost__json__array.insert.overload5 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 array::insert (1 of 5 overloads)]
|
||
|
||
Insert elements before the specified location.
|
||
[heading Synopsis]
|
||
```
|
||
iterator
|
||
insert(
|
||
const_iterator pos,
|
||
value const& v);
|
||
```
|
||
|
||
[heading Description]
|
||
This inserts a copy of `v` before `pos`. If `capacity() < size() + 1`, a reallocation occurs first, and all iterators and references are invalidated. Otherwise, only the iterators and references from the insertion point forward are invalidated. All past-the-end iterators are also invalidated.
|
||
|
||
[heading Complexity]
|
||
Constant plus linear in `std::distance(pos, end())`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
Iterator before which the content will be inserted. This may be the [link json.ref.boost__json__array.end `end()`] iterator.
|
||
]
|
||
]
|
||
[
|
||
[`v`
|
||
]
|
||
[
|
||
The value to insert. A copy will be made using container's associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
]
|
||
]
|
||
]
|
||
[heading Return Value]
|
||
An iterator to the inserted value
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 array::insert (2 of 5 overloads)]
|
||
|
||
Insert elements before the specified location.
|
||
[heading Synopsis]
|
||
```
|
||
iterator
|
||
insert(
|
||
const_iterator pos,
|
||
value&& v);
|
||
```
|
||
|
||
[heading Description]
|
||
This inserts `v` before `pos` via move-construction. If `capacity() < size() + 1`, a reallocation occurs first, and all iterators and references are invalidated. Otherwise, only the iterators and references from the insertion point forward are invalidated. All past-the-end iterators are also invalidated.
|
||
|
||
[heading Complexity]
|
||
Constant plus linear in `std::distance(pos, end())`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
Iterator before which the content will be inserted. This may be the [link json.ref.boost__json__array.end `end()`] iterator.
|
||
]
|
||
]
|
||
[
|
||
[`v`
|
||
]
|
||
[
|
||
The value to insert. Ownership of the value will be transferred via move construction, using the container's associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
]
|
||
]
|
||
]
|
||
[heading Return Value]
|
||
An iterator to the inserted value
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 array::insert (3 of 5 overloads)]
|
||
|
||
Insert elements before the specified location.
|
||
[heading Synopsis]
|
||
```
|
||
iterator
|
||
insert(
|
||
const_iterator pos,
|
||
std::size_t count,
|
||
value const& v);
|
||
```
|
||
|
||
[heading Description]
|
||
This inserts `count` copies of `v` before `pos`. If `capacity() < size() + count`, a reallocation occurs first, and all iterators and references are invalidated. Otherwise, only the iterators and references from the insertion point forward are invalidated. All past-the-end iterators are also invalidated.
|
||
|
||
[heading Complexity]
|
||
Linear in `count + std::distance(pos, end())`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
Iterator before which the content will be inserted. This may be the [link json.ref.boost__json__array.end `end()`] iterator.
|
||
]
|
||
]
|
||
[
|
||
[`count`
|
||
]
|
||
[
|
||
The number of copies to insert.
|
||
]
|
||
]
|
||
[
|
||
[`v`
|
||
]
|
||
[
|
||
The value to insert. Copies will be made using container's associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
]
|
||
]
|
||
]
|
||
[heading Return Value]
|
||
An iterator to the first inserted value, or `pos` if `count == 0`.
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 array::insert (4 of 5 overloads)]
|
||
|
||
Insert elements before the specified location.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class InputIt>
|
||
iterator
|
||
insert(
|
||
const_iterator pos,
|
||
InputIt first,
|
||
InputIt last);
|
||
```
|
||
|
||
[heading Description]
|
||
The elements in the range `{first, last)` are inserted in order. If `capacity() < size() + std::distance(first, last)`, a reallocation occurs first, and all iterators and references are invalidated. Otherwise, only the iterators and references from the insertion point forward are invalidated. All past-the-end iterators are also invalidated.
|
||
|
||
[heading Precondition]
|
||
`first` and `last` are not iterators into `*this`.
|
||
[heading Constraints]
|
||
|
||
```
|
||
not std::is_convertible_v<InputIt, value>
|
||
```
|
||
|
||
[heading Mandates]
|
||
|
||
```
|
||
std::is_constructible_v<value, std::iterator_traits<InputIt>::value_type>
|
||
```
|
||
|
||
[heading Complexity]
|
||
Linear in `std::distance(first, last) + std::distance(pos, end())`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Return Value]
|
||
An iterator to the first inserted value, or `pos` if `first == last`.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
Iterator before which the content will be inserted. This may be the [link json.ref.boost__json__array.end `end()`] iterator.
|
||
]
|
||
]
|
||
[
|
||
[`first`
|
||
]
|
||
[
|
||
An input iterator pointing to the first element to insert, or pointing to the end of the range.
|
||
]
|
||
]
|
||
[
|
||
[`last`
|
||
]
|
||
[
|
||
An input iterator pointing to the end of the range.
|
||
]
|
||
]
|
||
]
|
||
[heading Template Parameters]
|
||
[table [[Type][Description]]
|
||
[
|
||
[`InputIt`
|
||
]
|
||
[
|
||
a type satisfying the requirements of [*InputIterator].
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload5 array::insert (5 of 5 overloads)]
|
||
|
||
Insert elements before the specified location.
|
||
[heading Synopsis]
|
||
```
|
||
iterator
|
||
insert(
|
||
const_iterator pos,
|
||
std::initializer_list< value_ref > init);
|
||
```
|
||
|
||
[heading Description]
|
||
The elements in the initializer list `init` are inserted in order. If `capacity() < size() + init.size()`, a reallocation occurs first, and all iterators and references are invalidated. Otherwise, only the iterators and references from the insertion point forward are invalidated. All past-the-end iterators are also invalidated.
|
||
|
||
[heading Complexity]
|
||
Linear in `init.size() + std::distance(pos, end())`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
Iterator before which the content will be inserted. This may be the [link json.ref.boost__json__array.end `end()`] iterator.
|
||
]
|
||
]
|
||
[
|
||
[`init`
|
||
]
|
||
[
|
||
The initializer list to insert
|
||
]
|
||
]
|
||
]
|
||
[heading Return Value]
|
||
An iterator to the first inserted value, or `pos` if `init.size() == 0`.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:emplace array::emplace]
|
||
[indexterm2 emplace..array]
|
||
|
||
|
||
Insert a constructed element in-place.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class Arg>
|
||
iterator
|
||
emplace(
|
||
const_iterator pos,
|
||
Arg&& arg);
|
||
```
|
||
|
||
[heading Description]
|
||
Inserts a new element into the container directly before `pos`. The element is constructed using placement-new with the parameter `std::forward<Arg>(arg)`. If `capacity() < size() + 1`, a reallocation occurs first, and all iterators and references are invalidated. Otherwise, only the iterators and references from the insertion point forward are invalidated. All past-the-end iterators are also invalidated.
|
||
|
||
[heading Complexity]
|
||
Constant plus linear in `std::distance(pos, end())`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
Iterator before which the element will be inserted. This may be the [link json.ref.boost__json__array.end `end()`] iterator.
|
||
]
|
||
]
|
||
[
|
||
[`arg`
|
||
]
|
||
[
|
||
The argument to forward to the [link json.ref.boost__json__value `value`] constructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Return Value]
|
||
An iterator to the inserted element
|
||
|
||
[endsect]
|
||
|
||
[section:erase array::erase]
|
||
[indexterm2 erase..array]
|
||
|
||
|
||
Erase elements from the container.
|
||
```
|
||
iterator
|
||
``[link json.ref.boost__json__array.erase.overload1 erase]``(
|
||
const_iterator pos);
|
||
``[''''»''' [link json.ref.boost__json__array.erase.overload1 `more...`]]``
|
||
|
||
iterator
|
||
``[link json.ref.boost__json__array.erase.overload2 erase]``(
|
||
const_iterator first,
|
||
const_iterator last);
|
||
``[''''»''' [link json.ref.boost__json__array.erase.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 array::erase (1 of 2 overloads)]
|
||
|
||
Erase elements from the container.
|
||
[heading Synopsis]
|
||
```
|
||
iterator
|
||
erase(
|
||
const_iterator pos);
|
||
```
|
||
|
||
[heading Description]
|
||
The element at `pos` is removed.
|
||
|
||
[heading Complexity]
|
||
Constant plus linear in `std::distance(pos, end())`
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
Iterator to the element to remove
|
||
]
|
||
]
|
||
]
|
||
[heading Return Value]
|
||
Iterator following the last removed element. If the iterator `pos` refers to the last element, the [link json.ref.boost__json__array.end `end()`] iterator is returned.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 array::erase (2 of 2 overloads)]
|
||
|
||
Erase elements from the container.
|
||
[heading Synopsis]
|
||
```
|
||
iterator
|
||
erase(
|
||
const_iterator first,
|
||
const_iterator last);
|
||
```
|
||
|
||
[heading Description]
|
||
The elements in the range `{first, last)` are removed.
|
||
|
||
[heading Complexity]
|
||
Linear in `std::distance(first, last) + std::distance(pos, end())`
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`first`
|
||
]
|
||
[
|
||
An iterator pointing to the first element to erase, or pointing to the end of the range.
|
||
]
|
||
]
|
||
[
|
||
[`last`
|
||
]
|
||
[
|
||
An iterator pointing to one past the last element to erase, or pointing to the end of the range.
|
||
]
|
||
]
|
||
]
|
||
[heading Return Value]
|
||
Iterator following the last removed element. If the iterator `pos` refers to the last element, the [link json.ref.boost__json__array.end `end()`] iterator is returned.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:push_back array::push_back]
|
||
[indexterm2 push_back..array]
|
||
|
||
|
||
Add an element to the end.
|
||
```
|
||
void
|
||
``[link json.ref.boost__json__array.push_back.overload1 push_back]``(
|
||
value const& v);
|
||
``[''''»''' [link json.ref.boost__json__array.push_back.overload1 `more...`]]``
|
||
|
||
void
|
||
``[link json.ref.boost__json__array.push_back.overload2 push_back]``(
|
||
value&& v);
|
||
``[''''»''' [link json.ref.boost__json__array.push_back.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 array::push_back (1 of 2 overloads)]
|
||
|
||
Add an element to the end.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
push_back(
|
||
value const& v);
|
||
```
|
||
|
||
[heading Description]
|
||
This appends a copy of `v` to the container's elements. If `capacity() < size() + 1`, a reallocation occurs first, and all iterators and references are invalidated. Any past-the-end iterators are always invalidated.
|
||
|
||
[heading Complexity]
|
||
Amortized constant.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`v`
|
||
]
|
||
[
|
||
The value to insert. A copy will be made using container's associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 array::push_back (2 of 2 overloads)]
|
||
|
||
Add an element to the end.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
push_back(
|
||
value&& v);
|
||
```
|
||
|
||
[heading Description]
|
||
This appends `v` to the container's elements via move-construction. If `capacity() < size() + 1`, a reallocation occurs first, and all iterators and references are invalidated. Any past-the-end iterators are always invalidated.
|
||
|
||
[heading Complexity]
|
||
Amortized constant.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`v`
|
||
]
|
||
[
|
||
The value to insert. Ownership of the value will be transferred via move construction, using the container's associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:emplace_back array::emplace_back]
|
||
[indexterm2 emplace_back..array]
|
||
|
||
|
||
Append a constructed element in-place.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class Arg>
|
||
value&
|
||
emplace_back(
|
||
Arg&& arg);
|
||
```
|
||
|
||
[heading Description]
|
||
Appends a new element to the end of the container's list of elements. The element is constructed using placement-new with the parameter `std::forward<Arg>(arg)`. If `capacity() < size() + 1`, a reallocation occurs first, and all iterators and references are invalidated. Otherwise, only the iterators and references from the insertion point forward are invalidated. All past-the-end iterators are also invalidated.
|
||
|
||
[heading Complexity]
|
||
Amortized constant.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`arg`
|
||
]
|
||
[
|
||
The argument to forward to the [link json.ref.boost__json__value `value`] constructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Return Value]
|
||
A reference to the inserted element
|
||
|
||
[endsect]
|
||
|
||
[section:pop_back array::pop_back]
|
||
[indexterm2 pop_back..array]
|
||
|
||
|
||
Remove the last element.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
pop_back();
|
||
```
|
||
|
||
[heading Description]
|
||
The last element of the container is erased.
|
||
|
||
[heading Precondition]
|
||
`not empty()`
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:resize array::resize]
|
||
[indexterm2 resize..array]
|
||
|
||
|
||
Change the number of elements stored.
|
||
```
|
||
void
|
||
``[link json.ref.boost__json__array.resize.overload1 resize]``(
|
||
std::size_t count);
|
||
``[''''»''' [link json.ref.boost__json__array.resize.overload1 `more...`]]``
|
||
|
||
void
|
||
``[link json.ref.boost__json__array.resize.overload2 resize]``(
|
||
std::size_t count,
|
||
value const& v);
|
||
``[''''»''' [link json.ref.boost__json__array.resize.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 array::resize (1 of 2 overloads)]
|
||
|
||
Change the number of elements stored.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
resize(
|
||
std::size_t count);
|
||
```
|
||
|
||
[heading Description]
|
||
Resizes the container to contain `count` elements. If `capacity() < size() + count`, a reallocation occurs first, and all iterators and references are invalidated. Any past-the-end iterators are always invalidated.
|
||
|
||
* If `size() > count`, the container is reduced to its first `count` elements.
|
||
|
||
* If `size() < count`, additional null values are appended.
|
||
|
||
[heading Complexity]
|
||
Linear in `abs(size() - count)`, plus the cost of reallocation if [link json.ref.boost__json__array.capacity `capacity()`] is less than `count`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`count`
|
||
]
|
||
[
|
||
The new size of the container.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 array::resize (2 of 2 overloads)]
|
||
|
||
Change the number of elements stored.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
resize(
|
||
std::size_t count,
|
||
value const& v);
|
||
```
|
||
|
||
[heading Description]
|
||
Resizes the container to contain `count` elements. If `capacity() < size() + count`, a reallocation occurs first, and all iterators and references are invalidated. Any past-the-end iterators are always invalidated.
|
||
|
||
* If `size() > count`, the container is reduced to its first `count` elements.
|
||
|
||
* If `size() < count`, additional copies of `v` are appended.
|
||
|
||
[heading Complexity]
|
||
Linear in `abs(size() - count)`, plus the cost of reallocation if [link json.ref.boost__json__array.capacity `capacity()`] is less than `count`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`count`
|
||
]
|
||
[
|
||
The new size of the container.
|
||
]
|
||
]
|
||
[
|
||
[`v`
|
||
]
|
||
[
|
||
The [link json.ref.boost__json__value `value`] to copy into the new elements.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:max_size array::max_size]
|
||
[indexterm2 max_size..array]
|
||
|
||
|
||
Return the maximum number of elements any array can hold.
|
||
[heading Synopsis]
|
||
```
|
||
static
|
||
constexpr std::size_t
|
||
max_size();
|
||
```
|
||
|
||
[heading Description]
|
||
The maximum is an implementation-defined number. This value is a theoretical limit; at runtime, the actual maximum size may be less due to resource limits.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__array_kind_t array_kind_t]
|
||
|
||
A tag type used to select a [link json.ref.boost__json__value `value`] constructor overload.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/kind.hpp]
|
||
|
||
```
|
||
struct array_kind_t
|
||
```
|
||
|
||
[heading Description]
|
||
The library provides the constant [link json.ref.boost__json__array_kind `array_kind`] which may be used to select the [link json.ref.boost__json__value `value`] constructor that creates an empty [link json.ref.boost__json__array `array`].
|
||
|
||
[heading See Also]
|
||
[link json.ref.boost__json__array_kind `array_kind`]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__basic_parser basic_parser]
|
||
|
||
An incremental SAX parser for serialized JSON.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/basic_parser.hpp]
|
||
|
||
```
|
||
template<
|
||
class __Handler__>
|
||
class basic_parser
|
||
```
|
||
|
||
[heading Member Functions]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__basic_parser.basic_parser basic_parser] [role silver \[constructor\]]]
|
||
]
|
||
[Copy constructor (deleted) [br][role silver —][br]Constructor.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__basic_parser.done done]]
|
||
]
|
||
[Return true if a complete JSON has been parsed.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__basic_parser.fail fail]]
|
||
]
|
||
[Indicate a parsing failure.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__basic_parser.handler handler]]
|
||
]
|
||
[Return a reference to the handler.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__basic_parser.last_error last_error]]
|
||
]
|
||
[Return the last error.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__basic_parser.operator_eq_ operator=]]
|
||
]
|
||
[Copy assignment (deleted)
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__basic_parser.reset reset]]
|
||
]
|
||
[Reset the state, to parse a new document.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__basic_parser.write_some write_some]]
|
||
]
|
||
[Parse some of an input string as JSON, incrementally.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__basic_parser._basic_parser ~basic_parser] [role silver \[destructor\]]]
|
||
]
|
||
[Destructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
|
||
This implements a SAX-style parser, invoking a caller-supplied handler with each parsing event. To use, first declare a variable of type `basic_parser<T>` where `T` meets the handler requirements specified below. Then call [link json.ref.boost__json__basic_parser.write_some `write_some`] one or more times with the input, setting `more = false` on the final buffer. The parsing events are realized through member function calls on the handler, which exists as a data member of the parser.
|
||
|
||
|
||
The parser may dynamically allocate intermediate storage as needed to accommodate the nesting level of the input JSON. On subsequent invocations, the parser can cheaply re-use this memory, improving performance. This storage is freed when the parser is destroyed
|
||
|
||
[heading Usage]
|
||
|
||
To get the declaration and function definitions for this class it is necessary to include this file instead:
|
||
```
|
||
#include <boost/json/basic_parser_impl.hpp>
|
||
```
|
||
|
||
|
||
Users who wish to parse JSON into the DOM container [link json.ref.boost__json__value `value`] will not use this class directly; instead they will create an instance of [link json.ref.boost__json__parser `parser`] or [link json.ref.boost__json__stream_parser `stream_parser`] and use that instead. Alternatively, they may call the function [link json.ref.boost__json__parse `parse`]. This class is designed for users who wish to perform custom actions instead of building a [link json.ref.boost__json__value `value`]. For example, to produce a DOM from an external library.
|
||
|
||
|
||
[heading Remarks]
|
||
|
||
By default, only conforming JSON using UTF-8 encoding is accepted. However, select non-compliant syntax can be allowed by construction using a [link json.ref.boost__json__parse_options `parse_options`] set to desired values.
|
||
|
||
[heading Handler]
|
||
|
||
The handler provided must be implemented as an object of class type which defines each of the required event member functions below. The event functions return a `bool` where `true` indicates success, and `false` indicates failure. If the member function returns `false`, it must set the error code to a suitable value. This error code will be returned by the write function to the caller.
|
||
|
||
|
||
|
||
Handlers are required to declare the maximum limits on various elements. If these limits are exceeded during parsing, then parsing fails with an error.
|
||
|
||
|
||
The following declaration meets the parser's handler requirements:
|
||
|
||
```
|
||
struct handler
|
||
{
|
||
/// The maximum number of elements allowed in an array
|
||
static constexpr std::size_t max_array_size = -1;
|
||
|
||
/// The maximum number of elements allowed in an object
|
||
static constexpr std::size_t max_object_size = -1;
|
||
|
||
/// The maximum number of characters allowed in a string
|
||
static constexpr std::size_t max_string_size = -1;
|
||
|
||
/// The maximum number of characters allowed in a key
|
||
static constexpr std::size_t max_key_size = -1;
|
||
|
||
/// Called once when the JSON parsing begins.
|
||
///
|
||
/// @return `true` on success.
|
||
/// @param ec Set to the error, if any occurred.
|
||
///
|
||
bool on_document_begin( error_code& ec );
|
||
|
||
/// Called when the JSON parsing is done.
|
||
///
|
||
/// @return `true` on success.
|
||
/// @param ec Set to the error, if any occurred.
|
||
///
|
||
bool on_document_end( error_code& ec );
|
||
|
||
/// Called when the beginning of an array is encountered.
|
||
///
|
||
/// @return `true` on success.
|
||
/// @param ec Set to the error, if any occurred.
|
||
///
|
||
bool on_array_begin( error_code& ec );
|
||
|
||
/// Called when the end of the current array is encountered.
|
||
///
|
||
/// @return `true` on success.
|
||
/// @param n The number of elements in the array.
|
||
/// @param ec Set to the error, if any occurred.
|
||
///
|
||
bool on_array_end( std::size_t n, error_code& ec );
|
||
|
||
/// Called when the beginning of an object is encountered.
|
||
///
|
||
/// @return `true` on success.
|
||
/// @param ec Set to the error, if any occurred.
|
||
///
|
||
bool on_object_begin( error_code& ec );
|
||
|
||
/// Called when the end of the current object is encountered.
|
||
///
|
||
/// @return `true` on success.
|
||
/// @param n The number of elements in the object.
|
||
/// @param ec Set to the error, if any occurred.
|
||
///
|
||
bool on_object_end( std::size_t n, error_code& ec );
|
||
|
||
/// Called with characters corresponding to part of the current string.
|
||
///
|
||
/// @return `true` on success.
|
||
/// @param s The partial characters
|
||
/// @param n The total size of the string thus far
|
||
/// @param ec Set to the error, if any occurred.
|
||
///
|
||
bool on_string_part( string_view s, std::size_t n, error_code& ec );
|
||
|
||
/// Called with the last characters corresponding to the current string.
|
||
///
|
||
/// @return `true` on success.
|
||
/// @param s The remaining characters
|
||
/// @param n The total size of the string
|
||
/// @param ec Set to the error, if any occurred.
|
||
///
|
||
bool on_string( string_view s, std::size_t n, error_code& ec );
|
||
|
||
/// Called with characters corresponding to part of the current key.
|
||
///
|
||
/// @return `true` on success.
|
||
/// @param s The partial characters
|
||
/// @param n The total size of the key thus far
|
||
/// @param ec Set to the error, if any occurred.
|
||
///
|
||
bool on_key_part( string_view s, std::size_t n, error_code& ec );
|
||
|
||
/// Called with the last characters corresponding to the current key.
|
||
///
|
||
/// @return `true` on success.
|
||
/// @param s The remaining characters
|
||
/// @param n The total size of the key
|
||
/// @param ec Set to the error, if any occurred.
|
||
///
|
||
bool on_key( string_view s, std::size_t n, error_code& ec );
|
||
|
||
/// Called with the characters corresponding to part of the current number.
|
||
///
|
||
/// @return `true` on success.
|
||
/// @param s The partial characters
|
||
/// @param ec Set to the error, if any occurred.
|
||
///
|
||
bool on_number_part( string_view s, error_code& ec );
|
||
|
||
/// Called when a signed integer is parsed.
|
||
///
|
||
/// @return `true` on success.
|
||
/// @param i The value
|
||
/// @param s The remaining characters
|
||
/// @param ec Set to the error, if any occurred.
|
||
///
|
||
bool on_int64( int64_t i, string_view s, error_code& ec );
|
||
|
||
/// Called when an unsigend integer is parsed.
|
||
///
|
||
/// @return `true` on success.
|
||
/// @param u The value
|
||
/// @param s The remaining characters
|
||
/// @param ec Set to the error, if any occurred.
|
||
///
|
||
bool on_uint64( uint64_t u, string_view s, error_code& ec );
|
||
|
||
/// Called when a double is parsed.
|
||
///
|
||
/// @return `true` on success.
|
||
/// @param d The value
|
||
/// @param s The remaining characters
|
||
/// @param ec Set to the error, if any occurred.
|
||
///
|
||
bool on_double( double d, string_view s, error_code& ec );
|
||
|
||
/// Called when a boolean is parsed.
|
||
///
|
||
/// @return `true` on success.
|
||
/// @param b The value
|
||
/// @param s The remaining characters
|
||
/// @param ec Set to the error, if any occurred.
|
||
///
|
||
bool on_bool( bool b, error_code& ec );
|
||
|
||
/// Called when a null is parsed.
|
||
///
|
||
/// @return `true` on success.
|
||
/// @param ec Set to the error, if any occurred.
|
||
///
|
||
bool on_null( error_code& ec );
|
||
|
||
/// Called with characters corresponding to part of the current comment.
|
||
///
|
||
/// @return `true` on success.
|
||
/// @param s The partial characters.
|
||
/// @param ec Set to the error, if any occurred.
|
||
///
|
||
bool on_comment_part( string_view s, error_code& ec );
|
||
|
||
/// Called with the last characters corresponding to the current comment.
|
||
///
|
||
/// @return `true` on success.
|
||
/// @param s The remaining characters
|
||
/// @param ec Set to the error, if any occurred.
|
||
///
|
||
bool on_comment( string_view s, error_code& ec );
|
||
};
|
||
```
|
||
|
||
|
||
[heading See Also]
|
||
[link json.ref.boost__json__parse `parse`], [link json.ref.boost__json__stream_parser `stream_parser`].
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
[section:basic_parser basic_parser::basic_parser]
|
||
[indexterm2 basic_parser..basic_parser]
|
||
|
||
|
||
Copy constructor (deleted)
|
||
```
|
||
``[link json.ref.boost__json__basic_parser.basic_parser.overload1 basic_parser]``(
|
||
basic_parser const&);
|
||
``[''''»''' [link json.ref.boost__json__basic_parser.basic_parser.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Constructor.
|
||
```
|
||
template<
|
||
class... Args>
|
||
explicit
|
||
``[link json.ref.boost__json__basic_parser.basic_parser.overload2 basic_parser]``(
|
||
parse_options const& opt,
|
||
Args&&... args);
|
||
``[''''»''' [link json.ref.boost__json__basic_parser.basic_parser.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 basic_parser::basic_parser (1 of 2 overloads)]
|
||
|
||
Copy constructor (deleted)
|
||
[heading Synopsis]
|
||
```
|
||
basic_parser(
|
||
basic_parser const&);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 basic_parser::basic_parser (2 of 2 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class... Args>
|
||
basic_parser(
|
||
parse_options const& opt,
|
||
Args&&... args);
|
||
```
|
||
|
||
[heading Description]
|
||
This function constructs the parser with the specified options, with any additional arguments forwarded to the handler's constructor.
|
||
|
||
[heading Complexity]
|
||
Same as `Handler( std::forward< Args >( args )... )`.
|
||
[heading Exception Safety]
|
||
Same as `Handler( std::forward< Args >( args )... )`.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`opt`
|
||
]
|
||
[
|
||
Configuration settings for the parser. If this structure is default constructed, the parser will accept only standard JSON.
|
||
]
|
||
]
|
||
[
|
||
[`args`
|
||
]
|
||
[
|
||
Optional additional arguments forwarded to the handler's constructor.
|
||
]
|
||
]
|
||
]
|
||
[heading See Also]
|
||
parse_options
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:operator_eq_ basic_parser::operator=]
|
||
[indexterm2 operator=..basic_parser]
|
||
|
||
|
||
Copy assignment (deleted)
|
||
[heading Synopsis]
|
||
```
|
||
basic_parser&
|
||
operator=(
|
||
basic_parser const&);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:_basic_parser basic_parser::~basic_parser]
|
||
[indexterm2 ~basic_parser..basic_parser]
|
||
|
||
|
||
Destructor.
|
||
[heading Synopsis]
|
||
```
|
||
~basic_parser();
|
||
```
|
||
|
||
[heading Description]
|
||
All dynamically allocated internal memory is freed.
|
||
|
||
[heading Effects]
|
||
|
||
```
|
||
this->handler().~Handler()
|
||
```
|
||
|
||
[heading Complexity]
|
||
Same as `~Handler()`.
|
||
[heading Exception Safety]
|
||
Same as `~Handler()`.
|
||
|
||
[endsect]
|
||
|
||
[section:handler basic_parser::handler]
|
||
[indexterm2 handler..basic_parser]
|
||
|
||
|
||
Return a reference to the handler.
|
||
```
|
||
Handler&
|
||
``[link json.ref.boost__json__basic_parser.handler.overload1 handler]``();
|
||
``[''''»''' [link json.ref.boost__json__basic_parser.handler.overload1 `more...`]]``
|
||
|
||
Handler const&
|
||
``[link json.ref.boost__json__basic_parser.handler.overload2 handler]``() const;
|
||
``[''''»''' [link json.ref.boost__json__basic_parser.handler.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 basic_parser::handler (1 of 2 overloads)]
|
||
|
||
Return a reference to the handler.
|
||
[heading Synopsis]
|
||
```
|
||
Handler&
|
||
handler();
|
||
```
|
||
|
||
[heading Description]
|
||
This function provides access to the constructed instance of the handler owned by the parser.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 basic_parser::handler (2 of 2 overloads)]
|
||
|
||
Return a reference to the handler.
|
||
[heading Synopsis]
|
||
```
|
||
Handler const&
|
||
handler() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function provides access to the constructed instance of the handler owned by the parser.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:last_error basic_parser::last_error]
|
||
[indexterm2 last_error..basic_parser]
|
||
|
||
|
||
Return the last error.
|
||
[heading Synopsis]
|
||
```
|
||
error_code
|
||
last_error() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This returns the last error code which was generated in the most recent call to [link json.ref.boost__json__basic_parser.write_some `write_some`].
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:done basic_parser::done]
|
||
[indexterm2 done..basic_parser]
|
||
|
||
|
||
Return true if a complete JSON has been parsed.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
done() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns `true` when all of these conditions are met:
|
||
|
||
* A complete serialized JSON has been presented to the parser, and
|
||
|
||
* No error or exception has occurred since the parser was constructed, or since the last call to [link json.ref.boost__json__basic_parser.reset `reset`],
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:reset basic_parser::reset]
|
||
[indexterm2 reset..basic_parser]
|
||
|
||
|
||
Reset the state, to parse a new document.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
reset();
|
||
```
|
||
|
||
[heading Description]
|
||
This function discards the current parsing state, to prepare for parsing a new document. Dynamically allocated temporary memory used by the implementation is not deallocated.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:fail basic_parser::fail]
|
||
[indexterm2 fail..basic_parser]
|
||
|
||
|
||
Indicate a parsing failure.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
fail(
|
||
error_code ec);
|
||
```
|
||
|
||
[heading Description]
|
||
This changes the state of the parser to indicate that the parse has failed. A parser implementation can use this to fail the parser if needed due to external inputs.
|
||
|
||
[heading Remarks]
|
||
|
||
If `!ec`, the stored error code is unspecified.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`ec`
|
||
]
|
||
[
|
||
The error code to set. If the code does not indicate failure, an implementation-defined error code that indicates failure will be stored instead.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:write_some basic_parser::write_some]
|
||
[indexterm2 write_some..basic_parser]
|
||
|
||
|
||
Parse some of an input string as JSON, incrementally.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
write_some(
|
||
bool more,
|
||
char const* data,
|
||
std::size_t size,
|
||
error_code& ec);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This function parses the JSON in the specified buffer, calling the handler to emit each SAX parsing event. The parse proceeds from the current state, which is at the beginning of a new JSON or in the middle of the current JSON if any characters were already parsed.
|
||
|
||
|
||
The characters in the buffer are processed starting from the beginning, until one of the following conditions is met:
|
||
|
||
* All of the characters in the buffer have been parsed, or
|
||
|
||
* Some of the characters in the buffer have been parsed and the JSON is complete, or
|
||
|
||
* A parsing error occurs.
|
||
|
||
The supplied buffer does not need to contain the entire JSON. Subsequent calls can provide more serialized data, allowing JSON to be processed incrementally. The end of the serialized JSON can be indicated by passing `more = false`.
|
||
|
||
[heading Complexity]
|
||
Linear in `size`.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to the handler may throw. Upon error or exception, subsequent calls will fail until [link json.ref.boost__json__basic_parser.reset `reset`] is called to parse a new JSON.
|
||
[heading Return Value]
|
||
The number of characters successfully parsed, which may be smaller than `size`.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`more`
|
||
]
|
||
[
|
||
`true` if there are possibly more buffers in the current JSON, otherwise `false`.
|
||
]
|
||
]
|
||
[
|
||
[`data`
|
||
]
|
||
[
|
||
A pointer to a buffer of `size` characters to parse.
|
||
]
|
||
]
|
||
[
|
||
[`size`
|
||
]
|
||
[
|
||
The number of characters pointed to by `data`.
|
||
]
|
||
]
|
||
[
|
||
[`ec`
|
||
]
|
||
[
|
||
Set to the error, if any occurred.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__is_deallocate_trivial is_deallocate_trivial]
|
||
|
||
Return true if a memory resource's deallocate function has no effect.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/memory_resource.hpp]
|
||
|
||
```
|
||
template<
|
||
class T>
|
||
struct is_deallocate_trivial
|
||
```
|
||
|
||
[heading Static Members]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__is_deallocate_trivial.value value]]
|
||
]
|
||
[A bool equal to true if calls to `T::do_deallocate` have no effect.
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
This metafunction may be specialized to indicate to the library that calls to the `deallocate` function of a [link json.ref.boost__json__memory_resource `memory_resource`] have no effect. The implementation will elide such calls when it is safe to do so. By default, the implementation assumes that all memory resources require a call to `deallocate` for each memory region obtained by calling `allocate`.
|
||
|
||
[heading Example]
|
||
|
||
This example specializes the metafuction for `my_resource`, to indicate that calls to deallocate have no effect:
|
||
|
||
```
|
||
// Forward-declaration for a user-defined memory resource
|
||
struct my_resource;
|
||
|
||
// It is necessary to specialize the template from
|
||
// inside the namespace in which it is declared:
|
||
|
||
namespace boost {
|
||
namespace json {
|
||
|
||
template<>
|
||
struct is_deallocate_trivial< my_resource >
|
||
{
|
||
static constexpr bool value = true;
|
||
};
|
||
|
||
} // namespace json
|
||
} // namespace boost
|
||
```
|
||
|
||
It is usually not necessary for users to check this trait. Instead, they can call [link json.ref.boost__json__storage_ptr.is_deallocate_trivial `storage_ptr::is_deallocate_trivial`] to determine if the pointed-to memory resource has a trivial deallocate function.
|
||
|
||
[heading See Also]
|
||
[link json.ref.boost__json__memory_resource `memory_resource`], [link json.ref.boost__json__storage_ptr `storage_ptr`]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
[section:value is_deallocate_trivial::value]
|
||
[indexterm2 value..is_deallocate_trivial]
|
||
|
||
|
||
A bool equal to true if calls to `T::do_deallocate` have no effect.
|
||
[heading Synopsis]
|
||
```
|
||
static
|
||
constexpr bool value = false;
|
||
```
|
||
|
||
[heading Description]
|
||
The primary template sets `value` to false.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__is_deallocate_trivial_lt__monotonic_resource__gt_ is_deallocate_trivial< monotonic_resource >]
|
||
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/monotonic_resource.hpp]
|
||
|
||
```
|
||
template<>
|
||
struct is_deallocate_trivial< monotonic_resource >
|
||
```
|
||
|
||
[heading Static Members]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__is_deallocate_trivial_lt__monotonic_resource__gt_.value value]]
|
||
]
|
||
[
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
[section:value is_deallocate_trivial< monotonic_resource >::value]
|
||
[indexterm2 value..is_deallocate_trivial< monotonic_resource >]
|
||
|
||
|
||
[heading Synopsis]
|
||
```
|
||
static
|
||
constexpr bool value = true;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__is_deallocate_trivial_lt__static_resource__gt_ is_deallocate_trivial< static_resource >]
|
||
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/static_resource.hpp]
|
||
|
||
```
|
||
template<>
|
||
struct is_deallocate_trivial< static_resource >
|
||
```
|
||
|
||
[heading Static Members]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__is_deallocate_trivial_lt__static_resource__gt_.value value]]
|
||
]
|
||
[
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
[section:value is_deallocate_trivial< static_resource >::value]
|
||
[indexterm2 value..is_deallocate_trivial< static_resource >]
|
||
|
||
|
||
[heading Synopsis]
|
||
```
|
||
static
|
||
constexpr bool value = true;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__is_pilfer_constructible is_pilfer_constructible]
|
||
|
||
Metafunction returning `true` if `T` is ['PilferConstructible]
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/pilfer.hpp]
|
||
|
||
```
|
||
template<
|
||
class T>
|
||
struct is_pilfer_constructible
|
||
```
|
||
|
||
[heading Description]
|
||
If `T` can be pilfer constructed, this metafunction is equal to `std::true_type`. Otherwise it is equal to `std::false_type`.
|
||
|
||
[heading See Also]
|
||
[link json.ref.boost__json__pilfer `pilfer`], [link json.ref.boost__json__pilfered `pilfered`], [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0308r0.html Valueless Variants Considered Harmful]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__key_value_pair key_value_pair]
|
||
|
||
A key/value pair.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/value.hpp]
|
||
|
||
```
|
||
class key_value_pair
|
||
```
|
||
|
||
[heading Member Functions]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__key_value_pair.key key]]
|
||
]
|
||
[Return the key of this element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__key_value_pair.key_c_str key_c_str]]
|
||
]
|
||
[Return the key of this element as a null-terminated string.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__key_value_pair.key_value_pair key_value_pair] [role silver \[constructor\]]]
|
||
]
|
||
[Copy constructor. [br][role silver —][br]Move constructor. [br][role silver —][br]Pilfer constructor. [br][role silver —][br]Constructor.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__key_value_pair.operator_eq_ operator=]]
|
||
]
|
||
[Copy assignment (deleted).
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__key_value_pair.storage storage]]
|
||
]
|
||
[Return the associated memory resource.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__key_value_pair.value value]]
|
||
]
|
||
[Return the value of this element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__key_value_pair._key_value_pair ~key_value_pair] [role silver \[destructor\]]]
|
||
]
|
||
[Destructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
This is the type of element used by the [link json.ref.boost__json__object `object`] container.
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
[section:operator_eq_ key_value_pair::operator=]
|
||
[indexterm2 operator=..key_value_pair]
|
||
|
||
|
||
Copy assignment (deleted).
|
||
[heading Synopsis]
|
||
```
|
||
key_value_pair&
|
||
operator=(
|
||
key_value_pair const&);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:_key_value_pair key_value_pair::~key_value_pair]
|
||
[indexterm2 ~key_value_pair..key_value_pair]
|
||
|
||
|
||
Destructor.
|
||
[heading Synopsis]
|
||
```
|
||
~key_value_pair();
|
||
```
|
||
|
||
[heading Description]
|
||
The value is destroyed and all internally allocated memory is freed.
|
||
|
||
[endsect]
|
||
|
||
[section:key_value_pair key_value_pair::key_value_pair]
|
||
[indexterm2 key_value_pair..key_value_pair]
|
||
|
||
|
||
Copy constructor.
|
||
```
|
||
``[link json.ref.boost__json__key_value_pair.key_value_pair.overload1 key_value_pair]``(
|
||
key_value_pair const& other);
|
||
``[''''»''' [link json.ref.boost__json__key_value_pair.key_value_pair.overload1 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__key_value_pair.key_value_pair.overload2 key_value_pair]``(
|
||
key_value_pair const& other,
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__key_value_pair.key_value_pair.overload2 `more...`]]``
|
||
```
|
||
|
||
|
||
Move constructor.
|
||
```
|
||
``[link json.ref.boost__json__key_value_pair.key_value_pair.overload3 key_value_pair]``(
|
||
key_value_pair&& other);
|
||
``[''''»''' [link json.ref.boost__json__key_value_pair.key_value_pair.overload3 `more...`]]``
|
||
```
|
||
|
||
|
||
Pilfer constructor.
|
||
```
|
||
``[link json.ref.boost__json__key_value_pair.key_value_pair.overload4 key_value_pair]``(
|
||
pilfered< key_value_pair > other);
|
||
``[''''»''' [link json.ref.boost__json__key_value_pair.key_value_pair.overload4 `more...`]]``
|
||
```
|
||
|
||
|
||
Constructor.
|
||
```
|
||
template<
|
||
class... Args>
|
||
explicit
|
||
``[link json.ref.boost__json__key_value_pair.key_value_pair.overload5 key_value_pair]``(
|
||
string_view key,
|
||
Args&&... args);
|
||
``[''''»''' [link json.ref.boost__json__key_value_pair.key_value_pair.overload5 `more...`]]``
|
||
|
||
explicit
|
||
``[link json.ref.boost__json__key_value_pair.key_value_pair.overload6 key_value_pair]``(
|
||
std::pair< string_view, json::value > const& p,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__key_value_pair.key_value_pair.overload6 `more...`]]``
|
||
|
||
explicit
|
||
``[link json.ref.boost__json__key_value_pair.key_value_pair.overload7 key_value_pair]``(
|
||
std::pair< string_view, json::value >&& p,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__key_value_pair.key_value_pair.overload7 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 key_value_pair::key_value_pair (1 of 7 overloads)]
|
||
|
||
Copy constructor.
|
||
[heading Synopsis]
|
||
```
|
||
key_value_pair(
|
||
key_value_pair const& other);
|
||
```
|
||
|
||
[heading Description]
|
||
This constructs a key/value pair with a copy of another key/value pair, using the same memory resource as `other`.
|
||
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The key/value pair to copy.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 key_value_pair::key_value_pair (2 of 7 overloads)]
|
||
|
||
Copy constructor.
|
||
[heading Synopsis]
|
||
```
|
||
key_value_pair(
|
||
key_value_pair const& other,
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
This constructs a key/value pair with a copy of another key/value pair, using the specified memory resource.
|
||
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The key/value pair to copy.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The element will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 key_value_pair::key_value_pair (3 of 7 overloads)]
|
||
|
||
Move constructor.
|
||
[heading Synopsis]
|
||
```
|
||
key_value_pair(
|
||
key_value_pair&& other);
|
||
```
|
||
|
||
[heading Description]
|
||
The pair is constructed by acquiring ownership of the contents of `other` and shared ownership of `other`'s memory resource.
|
||
|
||
[heading Remarks]
|
||
|
||
After construction, the moved-from pair holds an empty key, and a null value with its current storage pointer.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The pair to move.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 key_value_pair::key_value_pair (4 of 7 overloads)]
|
||
|
||
Pilfer constructor.
|
||
[heading Synopsis]
|
||
```
|
||
key_value_pair(
|
||
pilfered< key_value_pair > other);
|
||
```
|
||
|
||
[heading Description]
|
||
The pair is constructed by acquiring ownership of the contents of `other` using pilfer semantics. This is more efficient than move construction, when it is known that the moved-from object will be immediately destroyed afterwards.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The value to pilfer. After pilfer construction, `other` is not in a usable state and may only be destroyed.
|
||
]
|
||
]
|
||
]
|
||
[heading See Also]
|
||
[link json.ref.boost__json__pilfer `pilfer`], [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0308r0.html Valueless Variants Considered Harmful]
|
||
|
||
[endsect]
|
||
|
||
[section:overload5 key_value_pair::key_value_pair (5 of 7 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class... Args>
|
||
key_value_pair(
|
||
string_view key,
|
||
Args&&... args);
|
||
```
|
||
|
||
[heading Description]
|
||
This constructs a key/value pair.
|
||
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`key`
|
||
]
|
||
[
|
||
The key string to use.
|
||
]
|
||
]
|
||
[
|
||
[`args`
|
||
]
|
||
[
|
||
Optional arguments forwarded to the [link json.ref.boost__json__value `value`] constructor.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload6 key_value_pair::key_value_pair (6 of 7 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
key_value_pair(
|
||
std::pair< string_view, json::value > const& p,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
This constructs a key/value pair. A copy of the specified value is made, using the specified memory resource.
|
||
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`p`
|
||
]
|
||
[
|
||
A `std::pair` with the key string and [link json.ref.boost__json__value `value`] to construct with.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The element will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload7 key_value_pair::key_value_pair (7 of 7 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
key_value_pair(
|
||
std::pair< string_view, json::value >&& p,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
This constructs a key/value pair. Ownership of the specified value is transferred by move construction.
|
||
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`p`
|
||
]
|
||
[
|
||
A `std::pair` with the key string and [link json.ref.boost__json__value `value`] to construct with.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The element will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:storage key_value_pair::storage]
|
||
[indexterm2 storage..key_value_pair]
|
||
|
||
|
||
Return the associated memory resource.
|
||
[heading Synopsis]
|
||
```
|
||
storage_ptr const&
|
||
storage() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This returns a pointer to the memory resource used to construct the value.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:key key_value_pair::key]
|
||
[indexterm2 key..key_value_pair]
|
||
|
||
|
||
Return the key of this element.
|
||
[heading Synopsis]
|
||
```
|
||
string_view const
|
||
key() const;
|
||
```
|
||
|
||
[heading Description]
|
||
After construction, the key may not be modified.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:key_c_str key_value_pair::key_c_str]
|
||
[indexterm2 key_c_str..key_value_pair]
|
||
|
||
|
||
Return the key of this element as a null-terminated string.
|
||
[heading Synopsis]
|
||
```
|
||
char const*
|
||
key_c_str() const;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:value key_value_pair::value]
|
||
[indexterm2 value..key_value_pair]
|
||
|
||
|
||
Return the value of this element.
|
||
```
|
||
json::value const&
|
||
``[link json.ref.boost__json__key_value_pair.value.overload1 value]``() const;
|
||
``[''''»''' [link json.ref.boost__json__key_value_pair.value.overload1 `more...`]]``
|
||
|
||
json::value&
|
||
``[link json.ref.boost__json__key_value_pair.value.overload2 value]``();
|
||
``[''''»''' [link json.ref.boost__json__key_value_pair.value.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 key_value_pair::value (1 of 2 overloads)]
|
||
|
||
Return the value of this element.
|
||
[heading Synopsis]
|
||
```
|
||
json::value const&
|
||
value() const;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 key_value_pair::value (2 of 2 overloads)]
|
||
|
||
Return the value of this element.
|
||
[heading Synopsis]
|
||
```
|
||
json::value&
|
||
value();
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__memory_resource memory_resource]
|
||
|
||
The type of memory resource used by the library.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/memory_resource.hpp]
|
||
|
||
```
|
||
class memory_resource
|
||
```
|
||
|
||
[heading Description]
|
||
This type alias is set depending on how the library is configured:
|
||
|
||
[heading Use with Boost]
|
||
|
||
If the macro `BOOST_JSON_STANDALONE` is not defined, this type will be an alias for `boost::container::pmr::memory_resource`. Compiling a program using the library will require Boost, and a compiler conforming to C++11 or later.
|
||
|
||
[heading Use without Boost]
|
||
|
||
If the macro `BOOST_JSON_STANDALONE` is defined, this type will be an alias for `std::pmr::memory_resource`. Compiling a program using the library will require only a compiler conforming to C++17 or later.
|
||
|
||
[heading See Also]
|
||
[@https://en.cppreference.com/w/cpp/memory/memory_resource https://en.cppreference.com/w/cpp/memory/memory_resource]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__monotonic_resource monotonic_resource]
|
||
|
||
A dynamically allocating resource with a trivial deallocate.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/monotonic_resource.hpp]
|
||
|
||
```
|
||
class monotonic_resource :
|
||
public memory_resource
|
||
```
|
||
|
||
[heading Member Functions]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__monotonic_resource.monotonic_resource monotonic_resource] [role silver \[constructor\]]]
|
||
]
|
||
[Constructor. [br][role silver —][br]Copy constructor (deleted)
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__monotonic_resource.operator_eq_ operator=]]
|
||
]
|
||
[Copy assignment (deleted)
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__monotonic_resource.release release]]
|
||
]
|
||
[Release all allocated memory.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__monotonic_resource._monotonic_resource ~monotonic_resource] [role silver \[destructor\]]]
|
||
]
|
||
[Destructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
|
||
This memory resource is a special-purpose resource that releases allocated memory only when the resource is destroyed (or when [link json.ref.boost__json__monotonic_resource.release `release`] is called). It has a trivial deallocate function; that is, the metafunction [link json.ref.boost__json__is_deallocate_trivial `is_deallocate_trivial`] returns `true`.
|
||
|
||
|
||
The resource can be constructed with an initial buffer. If there is no initial buffer, or if the buffer is exhausted, subsequent dynamic allocations are made from the system heap. The size of buffers obtained in this fashion follow a geometric progression.
|
||
|
||
|
||
The purpose of this resource is to optimize the use case for performing many allocations, followed by deallocating everything at once. This is precisely the pattern of memory allocation which occurs when parsing: allocation is performed for each parsed element, and when the the resulting [link json.ref.boost__json__value `value`] is no longer needed, the entire structure is destroyed. However, it is not suited for modifying the value after parsing is complete; reallocations waste memory, since the older buffer is not reclaimed until the resource is destroyed.
|
||
|
||
[heading Example]
|
||
|
||
This parses a JSON into a value which uses a local stack buffer, then prints the result.
|
||
|
||
```
|
||
unsigned char buf\[ 4000 \];
|
||
monotonic_resource mr( buf );
|
||
|
||
// Parse the string, using our memory resource
|
||
auto const jv = parse( "\[1,2,3\]", &mr );
|
||
|
||
// Print the JSON
|
||
std::cout << jv;
|
||
```
|
||
|
||
|
||
[heading Remarks]
|
||
The total amount of memory dynamically allocated is monotonically increasing; That is, it never decreases.
|
||
[heading Thread Safety]
|
||
Members of the same instance may not be called concurrently.
|
||
[heading See Also]
|
||
[@https://en.wikipedia.org/wiki/Region-based_memory_management https://en.wikipedia.org/wiki/Region-based_memory_management]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
[section:monotonic_resource monotonic_resource::monotonic_resource]
|
||
[indexterm2 monotonic_resource..monotonic_resource]
|
||
|
||
|
||
Constructor.
|
||
```
|
||
``[link json.ref.boost__json__monotonic_resource.monotonic_resource.overload1 monotonic_resource]``(
|
||
unsigned char* buffer,
|
||
std::size_t size,
|
||
storage_ptr upstream = {});
|
||
``[''''»''' [link json.ref.boost__json__monotonic_resource.monotonic_resource.overload1 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__monotonic_resource.monotonic_resource.overload2 monotonic_resource]``(
|
||
std::byte* buffer,
|
||
std::size_t size,
|
||
storage_ptr upstream);
|
||
``[''''»''' [link json.ref.boost__json__monotonic_resource.monotonic_resource.overload2 `more...`]]``
|
||
|
||
template<
|
||
std::size_t N>
|
||
explicit
|
||
``[link json.ref.boost__json__monotonic_resource.monotonic_resource.overload3 monotonic_resource]``(
|
||
unsigned char(&) buffer \[N\],
|
||
storage_ptr upstream = {});
|
||
``[''''»''' [link json.ref.boost__json__monotonic_resource.monotonic_resource.overload3 `more...`]]``
|
||
|
||
template<
|
||
std::size_t N>
|
||
explicit
|
||
``[link json.ref.boost__json__monotonic_resource.monotonic_resource.overload4 monotonic_resource]``(
|
||
std::byte(&) buffer \[N\],
|
||
storage_ptr upstream = {});
|
||
``[''''»''' [link json.ref.boost__json__monotonic_resource.monotonic_resource.overload4 `more...`]]``
|
||
|
||
explicit
|
||
``[link json.ref.boost__json__monotonic_resource.monotonic_resource.overload6 monotonic_resource]``(
|
||
std::size_t initial_size = 1024,
|
||
storage_ptr upstream = {});
|
||
``[''''»''' [link json.ref.boost__json__monotonic_resource.monotonic_resource.overload6 `more...`]]``
|
||
```
|
||
|
||
|
||
Copy constructor (deleted)
|
||
```
|
||
``[link json.ref.boost__json__monotonic_resource.monotonic_resource.overload5 monotonic_resource]``(
|
||
monotonic_resource const&);
|
||
``[''''»''' [link json.ref.boost__json__monotonic_resource.monotonic_resource.overload5 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 monotonic_resource::monotonic_resource (1 of 6 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
monotonic_resource(
|
||
unsigned char* buffer,
|
||
std::size_t size,
|
||
storage_ptr upstream = {});
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This constructs the resource and indicates that subsequent allocations should use the specified caller-owned buffer. When this buffer is exhausted, dynamic allocations from the upstream resource are made.
|
||
|
||
|
||
This constructor is guaranteed not to perform any dynamic allocations.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`buffer`
|
||
]
|
||
[
|
||
The buffer to use. Ownership is not transferred; the caller is responsible for ensuring that the lifetime of the buffer extends until the resource is destroyed.
|
||
]
|
||
]
|
||
[
|
||
[`size`
|
||
]
|
||
[
|
||
The number of valid bytes pointed to by `buffer`.
|
||
]
|
||
]
|
||
[
|
||
[`upstream`
|
||
]
|
||
[
|
||
An optional upstream memory resource to use for performing internal dynamic allocations. If this parameter is omitted, the default resource is used.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 monotonic_resource::monotonic_resource (2 of 6 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
monotonic_resource(
|
||
std::byte* buffer,
|
||
std::size_t size,
|
||
storage_ptr upstream);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This constructs the resource and indicates that subsequent allocations should use the specified caller-owned buffer. When this buffer is exhausted, dynamic allocations from the upstream resource are made.
|
||
|
||
|
||
This constructor is guaranteed not to perform any dynamic allocations.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`buffer`
|
||
]
|
||
[
|
||
The buffer to use. Ownership is not transferred; the caller is responsible for ensuring that the lifetime of the buffer extends until the resource is destroyed.
|
||
]
|
||
]
|
||
[
|
||
[`size`
|
||
]
|
||
[
|
||
The number of valid bytes pointed to by `buffer`.
|
||
]
|
||
]
|
||
[
|
||
[`upstream`
|
||
]
|
||
[
|
||
An optional upstream memory resource to use for performing internal dynamic allocations. If this parameter is omitted, the default resource is used.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 monotonic_resource::monotonic_resource (3 of 6 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
std::size_t N>
|
||
monotonic_resource(
|
||
unsigned char(&) buffer \[N\],
|
||
storage_ptr upstream = {});
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This constructs the resource and indicates that subsequent allocations should use the specified caller-owned buffer. When this buffer is exhausted, dynamic allocations from the upstream resource are made.
|
||
|
||
|
||
This constructor is guaranteed not to perform any dynamic allocations.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`buffer`
|
||
]
|
||
[
|
||
The buffer to use. Ownership is not transferred; the caller is responsible for ensuring that the lifetime of the buffer extends until the resource is destroyed.
|
||
]
|
||
]
|
||
[
|
||
[`upstream`
|
||
]
|
||
[
|
||
An optional upstream memory resource to use for performing internal dynamic allocations. If this parameter is omitted, the default resource is used.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 monotonic_resource::monotonic_resource (4 of 6 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
std::size_t N>
|
||
monotonic_resource(
|
||
std::byte(&) buffer \[N\],
|
||
storage_ptr upstream = {});
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This constructs the resource and indicates that subsequent allocations should use the specified caller-owned buffer. When this buffer is exhausted, dynamic allocations from the upstream resource are made.
|
||
|
||
|
||
This constructor is guaranteed not to perform any dynamic allocations.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`buffer`
|
||
]
|
||
[
|
||
The buffer to use. Ownership is not transferred; the caller is responsible for ensuring that the lifetime of the buffer extends until the resource is destroyed.
|
||
]
|
||
]
|
||
[
|
||
[`upstream`
|
||
]
|
||
[
|
||
An optional upstream memory resource to use for performing internal dynamic allocations. If this parameter is omitted, the default resource is used.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload5 monotonic_resource::monotonic_resource (5 of 6 overloads)]
|
||
|
||
Copy constructor (deleted)
|
||
[heading Synopsis]
|
||
```
|
||
monotonic_resource(
|
||
monotonic_resource const&);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload6 monotonic_resource::monotonic_resource (6 of 6 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
monotonic_resource(
|
||
std::size_t initial_size = 1024,
|
||
storage_ptr upstream = {});
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This constructs the resource and indicates that the first internal dynamic allocation shall be at least `initial_size` bytes.
|
||
|
||
|
||
This constructor is guaranteed not to perform any dynamic allocations.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`initial_size`
|
||
]
|
||
[
|
||
The size of the first internal dynamic allocation. If this is lower than the implementation-defined lower limit, then the lower limit is used instead.
|
||
]
|
||
]
|
||
[
|
||
[`upstream`
|
||
]
|
||
[
|
||
An optional upstream memory resource to use for performing internal dynamic allocations. If this parameter is omitted, the default resource is used.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:operator_eq_ monotonic_resource::operator=]
|
||
[indexterm2 operator=..monotonic_resource]
|
||
|
||
|
||
Copy assignment (deleted)
|
||
[heading Synopsis]
|
||
```
|
||
monotonic_resource&
|
||
operator=(
|
||
monotonic_resource const&);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:_monotonic_resource monotonic_resource::~monotonic_resource]
|
||
[indexterm2 ~monotonic_resource..monotonic_resource]
|
||
|
||
|
||
Destructor.
|
||
[heading Synopsis]
|
||
```
|
||
~monotonic_resource();
|
||
```
|
||
|
||
[heading Description]
|
||
Deallocates all the memory owned by this resource.
|
||
|
||
[heading Effects]
|
||
|
||
```
|
||
this->release();
|
||
```
|
||
|
||
[heading Complexity]
|
||
Linear in the number of deallocations performed.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:release monotonic_resource::release]
|
||
[indexterm2 release..monotonic_resource]
|
||
|
||
|
||
Release all allocated memory.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
release();
|
||
```
|
||
|
||
[heading Description]
|
||
This function deallocates all allocated memory. If an initial buffer was provided upon construction, then all of the bytes will be available again for allocation. Allocated memory is deallocated even if deallocate has not been called for some of the allocated blocks.
|
||
|
||
[heading Complexity]
|
||
Linear in the number of deallocations performed.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__object object]
|
||
|
||
A dynamically sized associative container of JSON key/value pairs.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/object.hpp]
|
||
|
||
```
|
||
class object
|
||
```
|
||
|
||
[heading Types]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__object.allocator_type allocator_type]]
|
||
]
|
||
[The type of ['Allocator] returned by [link json.ref.boost__json__object.get_allocator `get_allocator`].
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.const_iterator const_iterator]]
|
||
]
|
||
[A const random access iterator to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.const_pointer const_pointer]]
|
||
]
|
||
[A const pointer to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.const_reference const_reference]]
|
||
]
|
||
[A const reference to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.const_reverse_iterator const_reverse_iterator]]
|
||
]
|
||
[A const reverse random access iterator to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.difference_type difference_type]]
|
||
]
|
||
[The type used to represent signed integers.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.iterator iterator]]
|
||
]
|
||
[A random access iterator to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.key_type key_type]]
|
||
]
|
||
[The type of keys.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.mapped_type mapped_type]]
|
||
]
|
||
[The type of mapped values.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.pointer pointer]]
|
||
]
|
||
[A pointer to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.reference reference]]
|
||
]
|
||
[A reference to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.reverse_iterator reverse_iterator]]
|
||
]
|
||
[A reverse random access iterator to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.size_type size_type]]
|
||
]
|
||
[The type used to represent unsigned integers.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.value_type value_type]]
|
||
]
|
||
[The element type.
|
||
]
|
||
]
|
||
]
|
||
[heading Member Functions]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__object.at at]]
|
||
]
|
||
[Access the specified element, with bounds checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.begin begin]]
|
||
]
|
||
[Return an iterator to the first element. [br][role silver —][br]Return a const iterator to the first element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.capacity capacity]]
|
||
]
|
||
[Return the number of elements that can be held in currently allocated memory.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.cbegin cbegin]]
|
||
]
|
||
[Return a const iterator to the first element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.cend cend]]
|
||
]
|
||
[Return a const iterator to the element following the last element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.clear clear]]
|
||
]
|
||
[Erase all elements.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.contains contains]]
|
||
]
|
||
[Return `true` if the key is found.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.count count]]
|
||
]
|
||
[Count the number of elements with a specific key.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.crbegin crbegin]]
|
||
]
|
||
[Return a const reverse iterator to the first element of the reversed container.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.crend crend]]
|
||
]
|
||
[Return a const reverse iterator to the element following the last element of the reversed container.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.emplace emplace]]
|
||
]
|
||
[Construct an element in-place.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.empty empty]]
|
||
]
|
||
[Return whether there are no elements.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.end end]]
|
||
]
|
||
[Return an iterator to the element following the last element. [br][role silver —][br]Return a const iterator to the element following the last element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.erase erase]]
|
||
]
|
||
[Erase an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.find find]]
|
||
]
|
||
[Find an element with a specific key.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.get_allocator get_allocator]]
|
||
]
|
||
[Return the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.if_contains if_contains]]
|
||
]
|
||
[Return a pointer to the value if the key is found, or null.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.insert insert]]
|
||
]
|
||
[Insert elements.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.insert_or_assign insert_or_assign]]
|
||
]
|
||
[Insert an element or assign to the current element if the key already exists.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.object object] [role silver \[constructor\]]]
|
||
]
|
||
[Default constructor. [br][role silver —][br]Constructor. [br][role silver —][br]Move constructor. [br][role silver —][br]Pilfer constructor. [br][role silver —][br]Copy constructor. [br][role silver —][br]Construct from initializer-list.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.operator_eq_ operator=]]
|
||
]
|
||
[Copy assignment. [br][role silver —][br]Move assignment. [br][role silver —][br]Assignment.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.operator_lb__rb_ operator\[\]]]
|
||
]
|
||
[Access or insert the specified element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.rbegin rbegin]]
|
||
]
|
||
[Return a reverse iterator to the first element of the reversed container. [br][role silver —][br]Return a const reverse iterator to the first element of the reversed container.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.rend rend]]
|
||
]
|
||
[Return a reverse iterator to the element following the last element of the reversed container. [br][role silver —][br]Return a const reverse iterator to the element following the last element of the reversed container.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.reserve reserve]]
|
||
]
|
||
[Increase the capacity to at least a certain amount.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.size size]]
|
||
]
|
||
[Return the number of elements.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.storage storage]]
|
||
]
|
||
[Return the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.swap swap]]
|
||
]
|
||
[Swap two objects.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object._object ~object] [role silver \[destructor\]]]
|
||
]
|
||
[Destructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Static Members]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__object.max_size max_size]]
|
||
]
|
||
[Return the maximum number of elements any object can hold.
|
||
]
|
||
]
|
||
]
|
||
[heading Friends]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__object.operator_not__eq_ operator!=]]
|
||
]
|
||
[Return `true` if two objects are not equal.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.operator_eq__eq_ operator==]]
|
||
]
|
||
[Return `true` if two objects are equal.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__object.swap swap]]
|
||
]
|
||
[Swap two objects.
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
|
||
This is an associative container whose elements are key/value pairs with unique keys.
|
||
|
||
|
||
The elements are stored contiguously; iterators are ordinary pointers, allowing random access pointer arithmetic for retrieving elements. In addition, the container maintains an internal index to speed up find operations, reducing the average complexity for most lookups and insertions.
|
||
|
||
|
||
Reallocations are usually costly operations in terms of performance, as elements are copied and the internal index must be rebuilt. The [link json.ref.boost__json__object.reserve `reserve`] function can be used to eliminate reallocations if the number of elements is known beforehand.
|
||
|
||
[heading Allocators]
|
||
|
||
All elements stored in the container, and their children if any, will use the same memory resource that was used to construct the container.
|
||
|
||
[heading Thread Safety]
|
||
|
||
Non-const member functions may not be called concurrently with any other member functions.
|
||
|
||
[heading Satisfies]
|
||
[@https://en.cppreference.com/w/cpp/named_req/ContiguousContainer ['ContiguousContainer]], [@https://en.cppreference.com/w/cpp/named_req/ReversibleContainer ['ReversibleContainer]], and [@https://en.cppreference.com/w/cpp/named_req/SequenceContainer ['SequenceContainer]].
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
[section:allocator_type object::allocator_type]
|
||
[indexterm2 allocator_type..object]
|
||
|
||
|
||
The type of ['Allocator] returned by [link json.ref.boost__json__object.get_allocator `get_allocator`].
|
||
[heading Synopsis]
|
||
```
|
||
using allocator_type = ``['see-below]``;
|
||
```
|
||
|
||
[heading Description]
|
||
This type is a [link json.ref.boost__json__polymorphic_allocator `polymorphic_allocator`].
|
||
|
||
[endsect]
|
||
|
||
[section:key_type object::key_type]
|
||
[indexterm2 key_type..object]
|
||
|
||
|
||
The type of keys.
|
||
[heading Synopsis]
|
||
```
|
||
using key_type = string_view;
|
||
```
|
||
|
||
[heading Description]
|
||
The function [link json.ref.boost__json__string.max_size `string::max_size`] returns the maximum allowed size of strings used as keys.
|
||
|
||
[endsect]
|
||
|
||
[section:mapped_type object::mapped_type]
|
||
[indexterm2 mapped_type..object]
|
||
|
||
|
||
The type of mapped values.
|
||
[heading Synopsis]
|
||
```
|
||
using mapped_type = value;
|
||
```
|
||
|
||
[heading Types]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__value.allocator_type allocator_type]]
|
||
]
|
||
[The type of ['Allocator] returned by [link json.ref.boost__json__value.get_allocator `get_allocator`].
|
||
]
|
||
]
|
||
]
|
||
[heading Member Functions]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_array as_array]]
|
||
]
|
||
[Return a reference to the underlying [link json.ref.boost__json__array `array`], or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_bool as_bool]]
|
||
]
|
||
[Return a reference to the underlying `bool`, or throw an exception. [br][role silver —][br]Return the underlying `bool`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_double as_double]]
|
||
]
|
||
[Return a reference to the underlying `double`, or throw an exception. [br][role silver —][br]Return the underlying `double`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_int64 as_int64]]
|
||
]
|
||
[Return a reference to the underlying `std::int64_t`, or throw an exception. [br][role silver —][br]Return the underlying `std::int64_t`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_object as_object]]
|
||
]
|
||
[Return a reference to the underlying `object`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_string as_string]]
|
||
]
|
||
[Return a reference to the underlying `string`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_uint64 as_uint64]]
|
||
]
|
||
[Return a reference to the underlying `std::uint64_t`, or throw an exception. [br][role silver —][br]Return the underlying `std::uint64_t`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.at at]]
|
||
]
|
||
[Access an element, with bounds checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_array emplace_array]]
|
||
]
|
||
[Return a reference to an [link json.ref.boost__json__array `array`], changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_bool emplace_bool]]
|
||
]
|
||
[Return a reference to a `bool`, changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_double emplace_double]]
|
||
]
|
||
[Return a reference to a `double`, changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_int64 emplace_int64]]
|
||
]
|
||
[Return a reference to a `std::int64_t`, changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_null emplace_null]]
|
||
]
|
||
[Change the kind to null, discarding the previous contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_object emplace_object]]
|
||
]
|
||
[Return a reference to an [link json.ref.boost__json__object `object`], changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_string emplace_string]]
|
||
]
|
||
[Return a reference to a [link json.ref.boost__json__string `string`], changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_uint64 emplace_uint64]]
|
||
]
|
||
[Return a reference to a `std::uint64_t`, changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_allocator get_allocator]]
|
||
]
|
||
[Return the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_array get_array]]
|
||
]
|
||
[Return a reference to the underlying `array`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_bool get_bool]]
|
||
]
|
||
[Return a reference to the underlying `bool`, without checking. [br][role silver —][br]Return the underlying `bool`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_double get_double]]
|
||
]
|
||
[Return a reference to the underlying `double`, without checking. [br][role silver —][br]Return the underlying `double`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_int64 get_int64]]
|
||
]
|
||
[Return a reference to the underlying `std::int64_t`, without checking. [br][role silver —][br]Return the underlying `std::int64_t`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_object get_object]]
|
||
]
|
||
[Return a reference to the underlying `object`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_string get_string]]
|
||
]
|
||
[Return a reference to the underlying `string`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_uint64 get_uint64]]
|
||
]
|
||
[Return a reference to the underlying `std::uint64_t`, without checking. [br][role silver —][br]Return the underlying `std::uint64_t`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_array if_array]]
|
||
]
|
||
[Return an [link json.ref.boost__json__array `array`] pointer if this is an array, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_bool if_bool]]
|
||
]
|
||
[Return a `bool` pointer if this is a boolean, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_double if_double]]
|
||
]
|
||
[Return a `double` pointer if this is a double, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_int64 if_int64]]
|
||
]
|
||
[Return an `int64_t` pointer if this is a signed integer, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_object if_object]]
|
||
]
|
||
[Return an [link json.ref.boost__json__object `object`] pointer if this is an object, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_string if_string]]
|
||
]
|
||
[Return a [link json.ref.boost__json__string `string`] pointer if this is a string, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_uint64 if_uint64]]
|
||
]
|
||
[Return a `uint64_t` pointer if this is an unsigned integer, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_array is_array]]
|
||
]
|
||
[Return `true` if this is an array.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_bool is_bool]]
|
||
]
|
||
[Return `true` if this is a bool.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_double is_double]]
|
||
]
|
||
[Return `true` if this is a double.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_int64 is_int64]]
|
||
]
|
||
[Return `true` if this is a signed integer.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_null is_null]]
|
||
]
|
||
[Returns true if this is a null.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_number is_number]]
|
||
]
|
||
[Returns true if this is a number.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_object is_object]]
|
||
]
|
||
[Return `true` if this is an object.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_primitive is_primitive]]
|
||
]
|
||
[Returns true if this is not an array or object.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_string is_string]]
|
||
]
|
||
[Return `true` if this is a string.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_structured is_structured]]
|
||
]
|
||
[Returns true if this is an array or object.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_uint64 is_uint64]]
|
||
]
|
||
[Return `true` if this is a unsigned integer.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.kind kind]]
|
||
]
|
||
[Returns the kind of this JSON value.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.operator_eq_ operator=]]
|
||
]
|
||
[Assignment. [br][role silver —][br]Copy assignment. [br][role silver —][br]Move assignment.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.storage storage]]
|
||
]
|
||
[Return the memory resource associated with the value.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.swap swap]]
|
||
]
|
||
[Swap the given values.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.to_number to_number]]
|
||
]
|
||
[Return the stored number cast to an arithmetic type.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.value value]]
|
||
]
|
||
[Default constructor. [br][role silver —][br]Constructor. [br][role silver —][br]Pilfer constructor. [br][role silver —][br]Copy constructor. [br][role silver —][br]Move constructor. [br][role silver —][br]Construct a null. [br][role silver —][br]Construct a bool. [br][role silver —][br]Construct a `std::int64_t`. [br][role silver —][br]Construct a `std::uint64_t`. [br][role silver —][br]Construct a `double`. [br][role silver —][br]Construct a [link json.ref.boost__json__string `string`]. [br][role silver —][br]Construct an [link json.ref.boost__json__array `array`]. [br][role silver —][br]Construct an [link json.ref.boost__json__object `object`]. [br][role silver —][br]Construct from an initializer-list.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value._value ~value] [role silver \[destructor\]]]
|
||
]
|
||
[Destructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Friends]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__value.operator_not__eq_ operator!=]]
|
||
]
|
||
[Return `true` if two values are not equal.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.operator_eq__eq_ operator==]]
|
||
]
|
||
[Return `true` if two values are equal.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.swap swap]]
|
||
]
|
||
[Swap the given values.
|
||
]
|
||
]
|
||
]
|
||
This is a [@https://en.cppreference.com/w/cpp/concepts/regular ['Regular]]. ['Regular] type which works like a variant of the basic JSON data types: array, object, string, number, boolean, and null.
|
||
|
||
[heading Thread Safety]
|
||
|
||
Distinct instances may be accessed concurrently. Non-const member functions of a shared instance may not be called concurrently with any other member functions of that instance.
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:value_type object::value_type]
|
||
[indexterm2 value_type..object]
|
||
|
||
|
||
The element type.
|
||
[heading Synopsis]
|
||
```
|
||
using value_type = key_value_pair;
|
||
```
|
||
|
||
[heading Member Functions]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__key_value_pair.key key]]
|
||
]
|
||
[Return the key of this element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__key_value_pair.key_c_str key_c_str]]
|
||
]
|
||
[Return the key of this element as a null-terminated string.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__key_value_pair.key_value_pair key_value_pair]]
|
||
]
|
||
[Copy constructor. [br][role silver —][br]Move constructor. [br][role silver —][br]Pilfer constructor. [br][role silver —][br]Constructor.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__key_value_pair.operator_eq_ operator=]]
|
||
]
|
||
[Copy assignment (deleted).
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__key_value_pair.storage storage]]
|
||
]
|
||
[Return the associated memory resource.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__key_value_pair.value value]]
|
||
]
|
||
[Return the value of this element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__key_value_pair._key_value_pair ~key_value_pair] [role silver \[destructor\]]]
|
||
]
|
||
[Destructor.
|
||
]
|
||
]
|
||
]
|
||
This is the type of element used by the [link json.ref.boost__json__object `object`] container.
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:size_type object::size_type]
|
||
[indexterm2 size_type..object]
|
||
|
||
|
||
The type used to represent unsigned integers.
|
||
[heading Synopsis]
|
||
```
|
||
using size_type = std::size_t;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:difference_type object::difference_type]
|
||
[indexterm2 difference_type..object]
|
||
|
||
|
||
The type used to represent signed integers.
|
||
[heading Synopsis]
|
||
```
|
||
using difference_type = std::ptrdiff_t;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:reference object::reference]
|
||
[indexterm2 reference..object]
|
||
|
||
|
||
A reference to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using reference = value_type&;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:const_reference object::const_reference]
|
||
[indexterm2 const_reference..object]
|
||
|
||
|
||
A const reference to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using const_reference = value_type const&;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:pointer object::pointer]
|
||
[indexterm2 pointer..object]
|
||
|
||
|
||
A pointer to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using pointer = value_type*;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:const_pointer object::const_pointer]
|
||
[indexterm2 const_pointer..object]
|
||
|
||
|
||
A const pointer to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using const_pointer = value_type const*;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:iterator object::iterator]
|
||
[indexterm2 iterator..object]
|
||
|
||
|
||
A random access iterator to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using iterator = value_type*;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:const_iterator object::const_iterator]
|
||
[indexterm2 const_iterator..object]
|
||
|
||
|
||
A const random access iterator to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using const_iterator = value_type const*;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:reverse_iterator object::reverse_iterator]
|
||
[indexterm2 reverse_iterator..object]
|
||
|
||
|
||
A reverse random access iterator to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using reverse_iterator = std::reverse_iterator< iterator >;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:const_reverse_iterator object::const_reverse_iterator]
|
||
[indexterm2 const_reverse_iterator..object]
|
||
|
||
|
||
A const reverse random access iterator to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using const_reverse_iterator = std::reverse_iterator< const_iterator >;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:swap object::swap]
|
||
[indexterm2 swap..object]
|
||
|
||
|
||
Swap two objects.
|
||
```
|
||
friend void
|
||
``[link json.ref.boost__json__object.swap.overload1 swap]``(
|
||
object& lhs,
|
||
object& rhs);
|
||
``[''''»''' [link json.ref.boost__json__object.swap.overload1 `more...`]]``
|
||
|
||
void
|
||
``[link json.ref.boost__json__object.swap.overload2 swap]``(
|
||
object& other);
|
||
``[''''»''' [link json.ref.boost__json__object.swap.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 object::swap (1 of 2 overloads)]
|
||
|
||
Swap two objects.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/object.hpp]
|
||
|
||
```
|
||
friend void
|
||
swap(
|
||
object& lhs,
|
||
object& rhs);
|
||
```
|
||
|
||
[heading Description]
|
||
Exchanges the contents of the object `lhs` with another object `rhs`. Ownership of the respective [link json.ref.boost__json__memory_resource `memory_resource`] objects is not transferred.
|
||
|
||
* If `*lhs.storage() == *rhs.storage()`, ownership of the underlying memory is swapped in constant time, with no possibility of exceptions. All iterators and references remain valid.
|
||
|
||
* If `*lhs.storage() != *rhs.storage()`, the contents are logically swapped by making a copy, which can throw. In this case all iterators and references are invalidated.
|
||
|
||
[heading Effects]
|
||
|
||
```
|
||
lhs.swap( rhs );
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant or linear in `lhs.size() + rhs.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`lhs`
|
||
]
|
||
[
|
||
The object to exchange.
|
||
]
|
||
]
|
||
[
|
||
[`rhs`
|
||
]
|
||
[
|
||
The object to exchange. If `&lhs == &rhs`, this function call has no effect.
|
||
]
|
||
]
|
||
]
|
||
[heading See Also]
|
||
[link json.ref.boost__json__object.swap `object::swap`]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 object::swap (2 of 2 overloads)]
|
||
|
||
Swap two objects.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
swap(
|
||
object& other);
|
||
```
|
||
|
||
[heading Description]
|
||
Exchanges the contents of this object with another object. Ownership of the respective [link json.ref.boost__json__memory_resource `memory_resource`] objects is not transferred.
|
||
|
||
* If `*other.storage() == *this->storage()`, ownership of the underlying memory is swapped in constant time, with no possibility of exceptions. All iterators and references remain valid.
|
||
|
||
* If `*other.storage() != *this->storage()`, the contents are logically swapped by making copies, which can throw. In this case all iterators and references are invalidated.
|
||
|
||
[heading Complexity]
|
||
Constant or linear in [link json.ref.boost__json__object.size `size()`] plus `other.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The object to swap with. If `this == &other`, this function call has no effect.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:operator_eq__eq_ object::operator==]
|
||
[indexterm2 operator==..object]
|
||
|
||
|
||
Return `true` if two objects are equal.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/object.hpp]
|
||
|
||
```
|
||
friend bool
|
||
operator==(
|
||
object const& lhs,
|
||
object const& rhs);
|
||
```
|
||
|
||
[heading Description]
|
||
Objects are equal when their sizes are the same, and when for each key in `lhs` there is a matching key in `rhs` with the same value.
|
||
|
||
[heading Complexity]
|
||
Constant, or linear (worst case quadratic) in `lhs.size()`.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:operator_not__eq_ object::operator!=]
|
||
[indexterm2 operator!=..object]
|
||
|
||
|
||
Return `true` if two objects are not equal.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/object.hpp]
|
||
|
||
```
|
||
friend bool
|
||
operator!=(
|
||
object const& lhs,
|
||
object const& rhs);
|
||
```
|
||
|
||
[heading Description]
|
||
Objects are equal when their sizes are the same, and when for each key in `lhs` there is a matching key in `rhs` with the same value.
|
||
|
||
[heading Complexity]
|
||
Constant, or linear (worst case quadratic) in `lhs.size()`.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:_object object::~object]
|
||
[indexterm2 ~object..object]
|
||
|
||
|
||
Destructor.
|
||
[heading Synopsis]
|
||
```
|
||
~object();
|
||
```
|
||
|
||
[heading Description]
|
||
The destructor for each element is called if needed, any used memory is deallocated, and shared ownership of the [link json.ref.boost__json__memory_resource `memory_resource`] is released.
|
||
|
||
[heading Complexity]
|
||
Constant, or linear in [link json.ref.boost__json__object.size `size()`].
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:object object::object]
|
||
[indexterm2 object..object]
|
||
|
||
|
||
Default constructor.
|
||
```
|
||
``[link json.ref.boost__json__object.object.overload1 object]``();
|
||
``[''''»''' [link json.ref.boost__json__object.object.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Constructor.
|
||
```
|
||
explicit
|
||
``[link json.ref.boost__json__object.object.overload2 object]``(
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__object.object.overload2 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__object.object.overload3 object]``(
|
||
std::size_t min_capacity,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__object.object.overload3 `more...`]]``
|
||
|
||
template<
|
||
class InputIt>
|
||
``[link json.ref.boost__json__object.object.overload4 object]``(
|
||
InputIt first,
|
||
InputIt last,
|
||
std::size_t min_capacity = 0,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__object.object.overload4 `more...`]]``
|
||
```
|
||
|
||
|
||
Move constructor.
|
||
```
|
||
``[link json.ref.boost__json__object.object.overload5 object]``(
|
||
object&& other);
|
||
``[''''»''' [link json.ref.boost__json__object.object.overload5 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__object.object.overload6 object]``(
|
||
object&& other,
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__object.object.overload6 `more...`]]``
|
||
```
|
||
|
||
|
||
Pilfer constructor.
|
||
```
|
||
``[link json.ref.boost__json__object.object.overload7 object]``(
|
||
pilfered< object > other);
|
||
``[''''»''' [link json.ref.boost__json__object.object.overload7 `more...`]]``
|
||
```
|
||
|
||
|
||
Copy constructor.
|
||
```
|
||
``[link json.ref.boost__json__object.object.overload8 object]``(
|
||
object const& other);
|
||
``[''''»''' [link json.ref.boost__json__object.object.overload8 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__object.object.overload9 object]``(
|
||
object const& other,
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__object.object.overload9 `more...`]]``
|
||
```
|
||
|
||
|
||
Construct from initializer-list.
|
||
```
|
||
``[link json.ref.boost__json__object.object.overload10 object]``(
|
||
std::initializer_list< std::pair< string_view, value_ref >> init,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__object.object.overload10 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__object.object.overload11 object]``(
|
||
std::initializer_list< std::pair< string_view, value_ref >> init,
|
||
std::size_t min_capacity,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__object.object.overload11 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 object::object (1 of 11 overloads)]
|
||
|
||
Default constructor.
|
||
[heading Synopsis]
|
||
```
|
||
object();
|
||
```
|
||
|
||
[heading Description]
|
||
The constructed object is empty with zero capacity, using the default memory resource.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 object::object (2 of 11 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
object(
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
The constructed object is empty with zero capacity, using the specified memory resource.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 object::object (3 of 11 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
object(
|
||
std::size_t min_capacity,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
The constructed object is empty with capacity equal to the specified minimum capacity, using the specified memory resource.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`min_capacity`
|
||
]
|
||
[
|
||
The minimum number of elements for which capacity is guaranteed without a subsequent reallocation.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 object::object (4 of 11 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class InputIt>
|
||
object(
|
||
InputIt first,
|
||
InputIt last,
|
||
std::size_t min_capacity = 0,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
The object is constructed with the elements in the range `{first, last)`, preserving order, using the specified memory resource. If there are elements with duplicate keys; that is, if multiple elements in the range have keys that compare equal, only the first equivalent element will be inserted.
|
||
|
||
[heading Constraints]
|
||
|
||
```
|
||
std::is_constructible_v<
|
||
key_value_pair,
|
||
std::iterator_traits<InputIt>::value_type>
|
||
```
|
||
|
||
[heading Complexity]
|
||
Linear in `std::distance(first, last)`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`first`
|
||
]
|
||
[
|
||
An input iterator pointing to the first element to insert, or pointing to the end of the range.
|
||
]
|
||
]
|
||
[
|
||
[`last`
|
||
]
|
||
[
|
||
An input iterator pointing to the end of the range.
|
||
]
|
||
]
|
||
[
|
||
[`min_capacity`
|
||
]
|
||
[
|
||
The minimum number of elements for which capacity is guaranteed without a subsequent reallocation. Upon construction, [link json.ref.boost__json__object.capacity `capacity()`] will be greater than or equal to this number.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
[heading Template Parameters]
|
||
[table [[Type][Description]]
|
||
[
|
||
[`InputIt`
|
||
]
|
||
[
|
||
a type satisfying the requirements of [*InputIterator].
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload5 object::object (5 of 11 overloads)]
|
||
|
||
Move constructor.
|
||
[heading Synopsis]
|
||
```
|
||
object(
|
||
object&& other);
|
||
```
|
||
|
||
[heading Description]
|
||
The object is constructed by acquiring ownership of the contents of `other` and shared ownership of `other`'s memory resource.
|
||
|
||
[heading Remarks]
|
||
|
||
After construction, the moved-from object behaves as if newly constructed with its current memory resource.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The object to move.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload6 object::object (6 of 11 overloads)]
|
||
|
||
Move constructor.
|
||
[heading Synopsis]
|
||
```
|
||
object(
|
||
object&& other,
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
The object is constructed with the contents of `other` by move semantics, using the specified memory resource:
|
||
|
||
* If `*other.storage() == *sp`, ownership of the underlying memory is transferred in constant time, with no possibility of exceptions. After construction, the moved-from object behaves as if newly constructed with its current storage pointer.
|
||
|
||
* If `*other.storage() != *sp`, an element-wise copy is performed, which may throw. In this case, the moved-from object is not changed.
|
||
|
||
[heading Complexity]
|
||
Constant or linear in `other.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The object to move.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload7 object::object (7 of 11 overloads)]
|
||
|
||
Pilfer constructor.
|
||
[heading Synopsis]
|
||
```
|
||
object(
|
||
pilfered< object > other);
|
||
```
|
||
|
||
[heading Description]
|
||
The object is constructed by acquiring ownership of the contents of `other` using pilfer semantics. This is more efficient than move construction, when it is known that the moved-from object will be immediately destroyed afterwards.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The value to pilfer. After pilfer construction, `other` is not in a usable state and may only be destroyed.
|
||
]
|
||
]
|
||
]
|
||
[heading See Also]
|
||
[link json.ref.boost__json__pilfer `pilfer`], [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0308r0.html Valueless Variants Considered Harmful]
|
||
|
||
[endsect]
|
||
|
||
[section:overload8 object::object (8 of 11 overloads)]
|
||
|
||
Copy constructor.
|
||
[heading Synopsis]
|
||
```
|
||
object(
|
||
object const& other);
|
||
```
|
||
|
||
[heading Description]
|
||
The object is constructed with a copy of the contents of `other`, using `other`'s memory resource.
|
||
|
||
[heading Complexity]
|
||
Linear in `other.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The object to copy.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload9 object::object (9 of 11 overloads)]
|
||
|
||
Copy constructor.
|
||
[heading Synopsis]
|
||
```
|
||
object(
|
||
object const& other,
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
The object is constructed with a copy of the contents of `other`, using the specified memory resource.
|
||
|
||
[heading Complexity]
|
||
Linear in `other.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The object to copy.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload10 object::object (10 of 11 overloads)]
|
||
|
||
Construct from initializer-list.
|
||
[heading Synopsis]
|
||
```
|
||
object(
|
||
std::initializer_list< std::pair< string_view, value_ref >> init,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
The object is constructed with a copy of the values in the initializer-list in order, using the specified memory resource. If there are elements with duplicate keys; that is, if multiple elements in the range have keys that compare equal, only the first equivalent element will be inserted.
|
||
|
||
[heading Complexity]
|
||
Linear in `init.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`init`
|
||
]
|
||
[
|
||
The initializer list to insert.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload11 object::object (11 of 11 overloads)]
|
||
|
||
Construct from initializer-list.
|
||
[heading Synopsis]
|
||
```
|
||
object(
|
||
std::initializer_list< std::pair< string_view, value_ref >> init,
|
||
std::size_t min_capacity,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
Storage for at least `min_capacity` elements is reserved, and then the object is constructed with a copy of the values in the initializer-list in order, using the specified memory resource. If there are elements with duplicate keys; that is, if multiple elements in the range have keys that compare equal, only the first equivalent element will be inserted.
|
||
|
||
[heading Complexity]
|
||
Linear in `init.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`init`
|
||
]
|
||
[
|
||
The initializer list to insert.
|
||
]
|
||
]
|
||
[
|
||
[`min_capacity`
|
||
]
|
||
[
|
||
The minimum number of elements for which capacity is guaranteed without a subsequent reallocation. Upon construction, [link json.ref.boost__json__object.capacity `capacity()`] will be greater than or equal to this number.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:operator_eq_ object::operator=]
|
||
[indexterm2 operator=..object]
|
||
|
||
|
||
Copy assignment.
|
||
```
|
||
object&
|
||
``[link json.ref.boost__json__object.operator_eq_.overload1 operator=]``(
|
||
object const& other);
|
||
``[''''»''' [link json.ref.boost__json__object.operator_eq_.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Move assignment.
|
||
```
|
||
object&
|
||
``[link json.ref.boost__json__object.operator_eq_.overload2 operator=]``(
|
||
object&& other);
|
||
``[''''»''' [link json.ref.boost__json__object.operator_eq_.overload2 `more...`]]``
|
||
```
|
||
|
||
|
||
Assignment.
|
||
```
|
||
object&
|
||
``[link json.ref.boost__json__object.operator_eq_.overload3 operator=]``(
|
||
std::initializer_list< std::pair< string_view, value_ref >> init);
|
||
``[''''»''' [link json.ref.boost__json__object.operator_eq_.overload3 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 object::operator= (1 of 3 overloads)]
|
||
|
||
Copy assignment.
|
||
[heading Synopsis]
|
||
```
|
||
object&
|
||
operator=(
|
||
object const& other);
|
||
```
|
||
|
||
[heading Description]
|
||
The contents of the object are replaced with an element-wise copy of `other`.
|
||
|
||
[heading Complexity]
|
||
Linear in [link json.ref.boost__json__object.size `size()`] plus `other.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The object to copy.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 object::operator= (2 of 3 overloads)]
|
||
|
||
Move assignment.
|
||
[heading Synopsis]
|
||
```
|
||
object&
|
||
operator=(
|
||
object&& other);
|
||
```
|
||
|
||
[heading Description]
|
||
The contents of the object are replaced with the contents of `other` using move semantics:
|
||
|
||
* If `*other.storage() == *sp`, ownership of the underlying memory is transferred in constant time, with no possibility of exceptions. After assignment, the moved-from object behaves as if newly constructed with its current storage pointer.
|
||
|
||
* If `*other.storage() != *sp`, an element-wise copy is performed, which may throw. In this case, the moved-from object is not changed.
|
||
|
||
[heading Complexity]
|
||
Constant or linear in [link json.ref.boost__json__object.size `size()`] plus `other.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The object to move.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 object::operator= (3 of 3 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
object&
|
||
operator=(
|
||
std::initializer_list< std::pair< string_view, value_ref >> init);
|
||
```
|
||
|
||
[heading Description]
|
||
Replaces the contents with the contents of an initializer list.
|
||
|
||
[heading Complexity]
|
||
Linear in [link json.ref.boost__json__object.size `size()`] plus average case linear in `init.size()`, worst case quadratic in `init.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`init`
|
||
]
|
||
[
|
||
The initializer list to copy.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:storage object::storage]
|
||
[indexterm2 storage..object]
|
||
|
||
|
||
Return the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
[heading Synopsis]
|
||
```
|
||
storage_ptr const&
|
||
storage() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This returns the [link json.ref.boost__json__memory_resource `memory_resource`] used by the container.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:get_allocator object::get_allocator]
|
||
[indexterm2 get_allocator..object]
|
||
|
||
|
||
Return the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
[heading Synopsis]
|
||
```
|
||
allocator_type
|
||
get_allocator() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns an instance of [link json.ref.boost__json__polymorphic_allocator `polymorphic_allocator`] constructed from the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:begin object::begin]
|
||
[indexterm2 begin..object]
|
||
|
||
|
||
Return an iterator to the first element.
|
||
```
|
||
iterator
|
||
``[link json.ref.boost__json__object.begin.overload1 begin]``();
|
||
``[''''»''' [link json.ref.boost__json__object.begin.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Return a const iterator to the first element.
|
||
```
|
||
const_iterator
|
||
``[link json.ref.boost__json__object.begin.overload2 begin]``() const;
|
||
``[''''»''' [link json.ref.boost__json__object.begin.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 object::begin (1 of 2 overloads)]
|
||
|
||
Return an iterator to the first element.
|
||
[heading Synopsis]
|
||
```
|
||
iterator
|
||
begin();
|
||
```
|
||
|
||
[heading Description]
|
||
If the container is empty, [link json.ref.boost__json__object.end `end()`] is returned.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 object::begin (2 of 2 overloads)]
|
||
|
||
Return a const iterator to the first element.
|
||
[heading Synopsis]
|
||
```
|
||
const_iterator
|
||
begin() const;
|
||
```
|
||
|
||
[heading Description]
|
||
If the container is empty, [link json.ref.boost__json__object.end `end()`] is returned.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:cbegin object::cbegin]
|
||
[indexterm2 cbegin..object]
|
||
|
||
|
||
Return a const iterator to the first element.
|
||
[heading Synopsis]
|
||
```
|
||
const_iterator
|
||
cbegin() const;
|
||
```
|
||
|
||
[heading Description]
|
||
If the container is empty, [link json.ref.boost__json__object.cend `cend()`] is returned.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:end object::end]
|
||
[indexterm2 end..object]
|
||
|
||
|
||
Return an iterator to the element following the last element.
|
||
```
|
||
iterator
|
||
``[link json.ref.boost__json__object.end.overload1 end]``();
|
||
``[''''»''' [link json.ref.boost__json__object.end.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Return a const iterator to the element following the last element.
|
||
```
|
||
const_iterator
|
||
``[link json.ref.boost__json__object.end.overload2 end]``() const;
|
||
``[''''»''' [link json.ref.boost__json__object.end.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 object::end (1 of 2 overloads)]
|
||
|
||
Return an iterator to the element following the last element.
|
||
[heading Synopsis]
|
||
```
|
||
iterator
|
||
end();
|
||
```
|
||
|
||
[heading Description]
|
||
The element acts as a placeholder; attempting to access it results in undefined behavior.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 object::end (2 of 2 overloads)]
|
||
|
||
Return a const iterator to the element following the last element.
|
||
[heading Synopsis]
|
||
```
|
||
const_iterator
|
||
end() const;
|
||
```
|
||
|
||
[heading Description]
|
||
The element acts as a placeholder; attempting to access it results in undefined behavior.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:cend object::cend]
|
||
[indexterm2 cend..object]
|
||
|
||
|
||
Return a const iterator to the element following the last element.
|
||
[heading Synopsis]
|
||
```
|
||
const_iterator
|
||
cend() const;
|
||
```
|
||
|
||
[heading Description]
|
||
The element acts as a placeholder; attempting to access it results in undefined behavior.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:rbegin object::rbegin]
|
||
[indexterm2 rbegin..object]
|
||
|
||
|
||
Return a reverse iterator to the first element of the reversed container.
|
||
```
|
||
reverse_iterator
|
||
``[link json.ref.boost__json__object.rbegin.overload1 rbegin]``();
|
||
``[''''»''' [link json.ref.boost__json__object.rbegin.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Return a const reverse iterator to the first element of the reversed container.
|
||
```
|
||
const_reverse_iterator
|
||
``[link json.ref.boost__json__object.rbegin.overload2 rbegin]``() const;
|
||
``[''''»''' [link json.ref.boost__json__object.rbegin.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 object::rbegin (1 of 2 overloads)]
|
||
|
||
Return a reverse iterator to the first element of the reversed container.
|
||
[heading Synopsis]
|
||
```
|
||
reverse_iterator
|
||
rbegin();
|
||
```
|
||
|
||
[heading Description]
|
||
The pointed-to element corresponds to the last element of the non-reversed container. If the container is empty, [link json.ref.boost__json__object.rend `rend()`] is returned.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 object::rbegin (2 of 2 overloads)]
|
||
|
||
Return a const reverse iterator to the first element of the reversed container.
|
||
[heading Synopsis]
|
||
```
|
||
const_reverse_iterator
|
||
rbegin() const;
|
||
```
|
||
|
||
[heading Description]
|
||
The pointed-to element corresponds to the last element of the non-reversed container. If the container is empty, [link json.ref.boost__json__object.rend `rend()`] is returned.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:crbegin object::crbegin]
|
||
[indexterm2 crbegin..object]
|
||
|
||
|
||
Return a const reverse iterator to the first element of the reversed container.
|
||
[heading Synopsis]
|
||
```
|
||
const_reverse_iterator
|
||
crbegin() const;
|
||
```
|
||
|
||
[heading Description]
|
||
The pointed-to element corresponds to the last element of the non-reversed container. If the container is empty, [link json.ref.boost__json__object.crend `crend()`] is returned.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:rend object::rend]
|
||
[indexterm2 rend..object]
|
||
|
||
|
||
Return a reverse iterator to the element following the last element of the reversed container.
|
||
```
|
||
reverse_iterator
|
||
``[link json.ref.boost__json__object.rend.overload1 rend]``();
|
||
``[''''»''' [link json.ref.boost__json__object.rend.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Return a const reverse iterator to the element following the last element of the reversed container.
|
||
```
|
||
const_reverse_iterator
|
||
``[link json.ref.boost__json__object.rend.overload2 rend]``() const;
|
||
``[''''»''' [link json.ref.boost__json__object.rend.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 object::rend (1 of 2 overloads)]
|
||
|
||
Return a reverse iterator to the element following the last element of the reversed container.
|
||
[heading Synopsis]
|
||
```
|
||
reverse_iterator
|
||
rend();
|
||
```
|
||
|
||
[heading Description]
|
||
The pointed-to element corresponds to the element preceding the first element of the non-reversed container. This element acts as a placeholder, attempting to access it results in undefined behavior.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 object::rend (2 of 2 overloads)]
|
||
|
||
Return a const reverse iterator to the element following the last element of the reversed container.
|
||
[heading Synopsis]
|
||
```
|
||
const_reverse_iterator
|
||
rend() const;
|
||
```
|
||
|
||
[heading Description]
|
||
The pointed-to element corresponds to the element preceding the first element of the non-reversed container. This element acts as a placeholder, attempting to access it results in undefined behavior.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:crend object::crend]
|
||
[indexterm2 crend..object]
|
||
|
||
|
||
Return a const reverse iterator to the element following the last element of the reversed container.
|
||
[heading Synopsis]
|
||
```
|
||
const_reverse_iterator
|
||
crend() const;
|
||
```
|
||
|
||
[heading Description]
|
||
The pointed-to element corresponds to the element preceding the first element of the non-reversed container. This element acts as a placeholder, attempting to access it results in undefined behavior.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:empty object::empty]
|
||
[indexterm2 empty..object]
|
||
|
||
|
||
Return whether there are no elements.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
empty() const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns `true` if there are no elements in the container, i.e. [link json.ref.boost__json__object.size `size()`] returns 0.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:size object::size]
|
||
[indexterm2 size..object]
|
||
|
||
|
||
Return the number of elements.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
size() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This returns the number of elements in the container.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:capacity object::capacity]
|
||
[indexterm2 capacity..object]
|
||
|
||
|
||
Return the number of elements that can be held in currently allocated memory.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
capacity() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This number may be larger than the value returned by [link json.ref.boost__json__object.size `size()`].
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:reserve object::reserve]
|
||
[indexterm2 reserve..object]
|
||
|
||
|
||
Increase the capacity to at least a certain amount.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
reserve(
|
||
std::size_t new_capacity);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This increases the [link json.ref.boost__json__object.capacity `capacity()`] to a value that is greater than or equal to `new_capacity`. If `new_capacity > capacity()`, new memory is allocated. Otherwise, the call has no effect. The number of elements and therefore the [link json.ref.boost__json__object.size `size()`] of the container is not changed.
|
||
|
||
|
||
If new memory is allocated, all iterators including any past-the-end iterators, and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated.
|
||
|
||
[heading Complexity]
|
||
Constant or average case linear in [link json.ref.boost__json__object.size `size()`], worst case quadratic.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`new_capacity`
|
||
]
|
||
[
|
||
The new minimum capacity.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`new_capacity > max_size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:clear object::clear]
|
||
[indexterm2 clear..object]
|
||
|
||
|
||
Erase all elements.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
clear();
|
||
```
|
||
|
||
[heading Description]
|
||
Erases all elements from the container without changing the capacity. After this call, [link json.ref.boost__json__object.size `size()`] returns zero. All references, pointers, and iterators are invalidated.
|
||
|
||
[heading Complexity]
|
||
Linear in [link json.ref.boost__json__object.size `size()`].
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:insert object::insert]
|
||
[indexterm2 insert..object]
|
||
|
||
|
||
Insert elements.
|
||
```
|
||
template<
|
||
class P>
|
||
std::pair< iterator, bool >
|
||
``[link json.ref.boost__json__object.insert.overload1 insert]``(
|
||
P&& p);
|
||
``[''''»''' [link json.ref.boost__json__object.insert.overload1 `more...`]]``
|
||
|
||
template<
|
||
class InputIt>
|
||
void
|
||
``[link json.ref.boost__json__object.insert.overload2 insert]``(
|
||
InputIt first,
|
||
InputIt last);
|
||
``[''''»''' [link json.ref.boost__json__object.insert.overload2 `more...`]]``
|
||
|
||
void
|
||
``[link json.ref.boost__json__object.insert.overload3 insert]``(
|
||
std::initializer_list< std::pair< string_view, value_ref >> init);
|
||
``[''''»''' [link json.ref.boost__json__object.insert.overload3 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 object::insert (1 of 3 overloads)]
|
||
|
||
Insert elements.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class P>
|
||
std::pair< iterator, bool >
|
||
insert(
|
||
P&& p);
|
||
```
|
||
|
||
[heading Description]
|
||
Inserts `p`, from which [link json.ref.boost__json__object.value_type `value_type`] must be constructible.
|
||
|
||
[heading Constraints]
|
||
|
||
```
|
||
std::is_constructible_v<value_type, P>
|
||
```
|
||
|
||
[heading Complexity]
|
||
Average case amortized constant, worst case linear in [link json.ref.boost__json__object.size `size()`].
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`p`
|
||
]
|
||
[
|
||
The value to insert.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
key is too long.
|
||
]
|
||
]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
[link json.ref.boost__json__object.size `size()`] >= max_size().
|
||
]
|
||
]
|
||
]
|
||
[heading Return Value]
|
||
A pair where `first` is an iterator to the existing or inserted element, and `second` is `true` if the insertion took place or `false` if the assignment took place.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 object::insert (2 of 3 overloads)]
|
||
|
||
Insert elements.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class InputIt>
|
||
void
|
||
insert(
|
||
InputIt first,
|
||
InputIt last);
|
||
```
|
||
|
||
[heading Description]
|
||
The elements in the range `{first, last)` whose keys are unique are inserted one at a time, in order. If there are elements with duplicate keys; that is, if multiple elements in the range have keys that compare equal, only the first equivalent element will be inserted.
|
||
|
||
[heading Precondition]
|
||
`first` and `last` are not iterators into `*this`.
|
||
[heading Constraints]
|
||
|
||
```
|
||
std::is_constructible_v<value_type, std::iterator_traits<InputIt>::value_type>
|
||
```
|
||
|
||
[heading Complexity ]
|
||
|
||
Linear in `std::distance(first, last)`.
|
||
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`first`
|
||
]
|
||
[
|
||
An input iterator pointing to the first element to insert, or pointing to the end of the range.
|
||
]
|
||
]
|
||
[
|
||
[`last`
|
||
]
|
||
[
|
||
An input iterator pointing to the end of the range.
|
||
]
|
||
]
|
||
]
|
||
[heading Template Parameters]
|
||
[table [[Type][Description]]
|
||
[
|
||
[`InputIt`
|
||
]
|
||
[
|
||
a type satisfying the requirements of [*InputIterator].
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 object::insert (3 of 3 overloads)]
|
||
|
||
Insert elements.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
insert(
|
||
std::initializer_list< std::pair< string_view, value_ref >> init);
|
||
```
|
||
|
||
[heading Description]
|
||
The elements in the initializer list whose keys are unique are inserted one at a time, in order. If there are elements with duplicate keys; that is, if multiple elements in the range have keys that compare equal, only the first equivalent element will be inserted.
|
||
|
||
[heading Complexity ]
|
||
|
||
Linear in `init.size()`.
|
||
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`init`
|
||
]
|
||
[
|
||
The initializer list to insert
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:insert_or_assign object::insert_or_assign]
|
||
[indexterm2 insert_or_assign..object]
|
||
|
||
|
||
Insert an element or assign to the current element if the key already exists.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class M>
|
||
std::pair< iterator, bool >
|
||
insert_or_assign(
|
||
string_view key,
|
||
M&& m);
|
||
```
|
||
|
||
[heading Description]
|
||
If the key equivalent to `key` already exists in the container. assigns `std::forward<M>(obj)` to the `mapped type` corresponding to the key. Otherwise, inserts the new value at the end as if by insert, constructing it from `value_type(key, std::forward<M>(obj))`.
|
||
If the insertion occurs and results in a rehashing of the container, all iterators are invalidated. Otherwise, iterators are not affected. References are not invalidated. Rehashing occurs only if the new number of elements is greater than [link json.ref.boost__json__object.capacity `capacity()`].
|
||
|
||
[heading Complexity]
|
||
Amortized constant on average, worst case linear in [link json.ref.boost__json__object.size `size()`].
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Return Value]
|
||
A `std::pair` where `first` is an iterator to the existing or inserted element, and `second` is `true` if the insertion took place or `false` if the assignment took place.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`key`
|
||
]
|
||
[
|
||
The key used for lookup and insertion
|
||
]
|
||
]
|
||
[
|
||
[`m`
|
||
]
|
||
[
|
||
The value to insert or assign
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
if key is too long
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:emplace object::emplace]
|
||
[indexterm2 emplace..object]
|
||
|
||
|
||
Construct an element in-place.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class Arg>
|
||
std::pair< iterator, bool >
|
||
emplace(
|
||
string_view key,
|
||
Arg&& arg);
|
||
```
|
||
|
||
[heading Description]
|
||
Inserts a new element into the container constructed in-place with the given argument if there is no element with the key in the container. The element is inserted after all the existing elements.
|
||
If the insertion occurs and results in a rehashing of the container, all iterators are invalidated. Otherwise, iterators are not affected. References are not invalidated. Rehashing occurs only if the new number of elements is greater than [link json.ref.boost__json__object.capacity `capacity()`].
|
||
|
||
[heading Complexity]
|
||
Amortized constant on average, worst case linear in [link json.ref.boost__json__object.size `size()`].
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Return Value]
|
||
A `std::pair` where `first` is an iterator to the existing or inserted element, and `second` is `true` if the insertion took place or `false` if the assignment took place.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`key`
|
||
]
|
||
[
|
||
The key used for lookup and insertion
|
||
]
|
||
]
|
||
[
|
||
[`arg`
|
||
]
|
||
[
|
||
The argument used to construct the value. This will be passed as `std::forward<Arg>(arg)` to the [link json.ref.boost__json__value `value`] constructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
if key is too long
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:erase object::erase]
|
||
[indexterm2 erase..object]
|
||
|
||
|
||
Erase an element.
|
||
```
|
||
iterator
|
||
``[link json.ref.boost__json__object.erase.overload1 erase]``(
|
||
const_iterator pos);
|
||
``[''''»''' [link json.ref.boost__json__object.erase.overload1 `more...`]]``
|
||
|
||
std::size_t
|
||
``[link json.ref.boost__json__object.erase.overload2 erase]``(
|
||
string_view key);
|
||
``[''''»''' [link json.ref.boost__json__object.erase.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 object::erase (1 of 2 overloads)]
|
||
|
||
Erase an element.
|
||
[heading Synopsis]
|
||
```
|
||
iterator
|
||
erase(
|
||
const_iterator pos);
|
||
```
|
||
|
||
[heading Description]
|
||
Remove the element pointed to by `pos`, which must be valid and dereferenceable. Thus the [link json.ref.boost__json__object.end `end()`] iterator (which is valid but cannot be dereferenced) cannot be used as a value for `pos`. References and iterators to the erased element are invalidated. Other iterators and references are not invalidated.
|
||
|
||
[heading Complexity]
|
||
Constant on average, worst case linear in [link json.ref.boost__json__object.size `size()`].
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Return Value]
|
||
An iterator following the last removed element.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
An iterator pointing to the element to be removed.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 object::erase (2 of 2 overloads)]
|
||
|
||
Erase an element.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
erase(
|
||
string_view key);
|
||
```
|
||
|
||
[heading Description]
|
||
Remove the element which matches `key`, if it exists. References and iterators to the erased element are invalidated. Other iterators and references are not invalidated.
|
||
|
||
[heading Complexity]
|
||
Constant on average, worst case linear in [link json.ref.boost__json__object.size `size()`].
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Return Value]
|
||
The number of elements removed, which will be either 0 or 1.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`key`
|
||
]
|
||
[
|
||
The key to match.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:at object::at]
|
||
[indexterm2 at..object]
|
||
|
||
|
||
Access the specified element, with bounds checking.
|
||
```
|
||
value&
|
||
``[link json.ref.boost__json__object.at.overload1 at]``(
|
||
string_view key);
|
||
``[''''»''' [link json.ref.boost__json__object.at.overload1 `more...`]]``
|
||
|
||
value const&
|
||
``[link json.ref.boost__json__object.at.overload2 at]``(
|
||
string_view key) const;
|
||
``[''''»''' [link json.ref.boost__json__object.at.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 object::at (1 of 2 overloads)]
|
||
|
||
Access the specified element, with bounds checking.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
at(
|
||
string_view key);
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a reference to the mapped value of the element that matches `key`, otherwise throws.
|
||
|
||
[heading Complexity]
|
||
Constant on average, worst case linear in [link json.ref.boost__json__object.size `size()`].
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Return Value]
|
||
A reference to the mapped value.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`key`
|
||
]
|
||
[
|
||
The key of the element to find.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::out_of_range`
|
||
]
|
||
[
|
||
if no such element exists.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 object::at (2 of 2 overloads)]
|
||
|
||
Access the specified element, with bounds checking.
|
||
[heading Synopsis]
|
||
```
|
||
value const&
|
||
at(
|
||
string_view key) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a constant reference to the mapped value of the element that matches `key`, otherwise throws.
|
||
|
||
[heading Complexity]
|
||
Constant on average, worst case linear in [link json.ref.boost__json__object.size `size()`].
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Return Value]
|
||
A reference to the mapped value.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`key`
|
||
]
|
||
[
|
||
The key of the element to find.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::out_of_range`
|
||
]
|
||
[
|
||
if no such element exists.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:operator_lb__rb_ object::operator\[\]]
|
||
[indexterm2 operator\[\]..object]
|
||
|
||
|
||
Access or insert the specified element.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator\[\](
|
||
string_view key);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
Returns a reference to the value that is mapped to a key equivalent to key, performing an insertion of a null value if such key does not already exist.
|
||
|
||
|
||
If an insertion occurs and results in a rehashing of the container, all iterators are invalidated. Otherwise iterators are not affected. References are not invalidated. Rehashing occurs only if the new number of elements is greater than [link json.ref.boost__json__object.capacity `capacity()`].
|
||
|
||
[heading Complexity]
|
||
Constant on average, worst case linear in [link json.ref.boost__json__object.size `size()`].
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Return Value]
|
||
A reference to the mapped value.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`key`
|
||
]
|
||
[
|
||
The key of the element to find.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:count object::count]
|
||
[indexterm2 count..object]
|
||
|
||
|
||
Count the number of elements with a specific key.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
count(
|
||
string_view key) const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns the count of the number of elements match `key`. The only possible return values are 0 and 1.
|
||
|
||
[heading Complexity]
|
||
Constant on average, worst case linear in [link json.ref.boost__json__object.size `size()`].
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`key`
|
||
]
|
||
[
|
||
The key of the element to find.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:find object::find]
|
||
[indexterm2 find..object]
|
||
|
||
|
||
Find an element with a specific key.
|
||
```
|
||
iterator
|
||
``[link json.ref.boost__json__object.find.overload1 find]``(
|
||
string_view key);
|
||
``[''''»''' [link json.ref.boost__json__object.find.overload1 `more...`]]``
|
||
|
||
const_iterator
|
||
``[link json.ref.boost__json__object.find.overload2 find]``(
|
||
string_view key) const;
|
||
``[''''»''' [link json.ref.boost__json__object.find.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 object::find (1 of 2 overloads)]
|
||
|
||
Find an element with a specific key.
|
||
[heading Synopsis]
|
||
```
|
||
iterator
|
||
find(
|
||
string_view key);
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns an iterator to the element matching `key` if it exists, otherwise returns [link json.ref.boost__json__object.end `end()`].
|
||
|
||
[heading Complexity]
|
||
Constant on average, worst case linear in [link json.ref.boost__json__object.size `size()`].
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`key`
|
||
]
|
||
[
|
||
The key of the element to find.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 object::find (2 of 2 overloads)]
|
||
|
||
Find an element with a specific key.
|
||
[heading Synopsis]
|
||
```
|
||
const_iterator
|
||
find(
|
||
string_view key) const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns a constant iterator to the element matching `key` if it exists, otherwise returns [link json.ref.boost__json__object.end `end()`].
|
||
|
||
[heading Complexity]
|
||
Constant on average, worst case linear in [link json.ref.boost__json__object.size `size()`].
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`key`
|
||
]
|
||
[
|
||
The key of the element to find.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:contains object::contains]
|
||
[indexterm2 contains..object]
|
||
|
||
|
||
Return `true` if the key is found.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
contains(
|
||
string_view key) const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns `true` if a key with the specified string is found.
|
||
|
||
[heading Effects]
|
||
|
||
```
|
||
return this->find(key) != this->end();
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant on average, worst case linear in [link json.ref.boost__json__object.size `size()`].
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`key`
|
||
]
|
||
[
|
||
The key of the element to find.
|
||
]
|
||
]
|
||
]
|
||
[heading See Also]
|
||
[link json.ref.boost__json__object.find `find`]
|
||
|
||
[endsect]
|
||
|
||
[section:if_contains object::if_contains]
|
||
[indexterm2 if_contains..object]
|
||
|
||
|
||
Return a pointer to the value if the key is found, or null.
|
||
```
|
||
value const*
|
||
``[link json.ref.boost__json__object.if_contains.overload1 if_contains]``(
|
||
string_view key) const;
|
||
``[''''»''' [link json.ref.boost__json__object.if_contains.overload1 `more...`]]``
|
||
|
||
value*
|
||
``[link json.ref.boost__json__object.if_contains.overload2 if_contains]``(
|
||
string_view key);
|
||
``[''''»''' [link json.ref.boost__json__object.if_contains.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 object::if_contains (1 of 2 overloads)]
|
||
|
||
Return a pointer to the value if the key is found, or null.
|
||
[heading Synopsis]
|
||
```
|
||
value const*
|
||
if_contains(
|
||
string_view key) const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function searches for a value with the given key, and returns a pointer to it if found. Otherwise it returns null.
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
if( auto p = obj.if_contains( "key" ) )
|
||
std::cout << *p;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant on average, worst case linear in [link json.ref.boost__json__object.size `size()`].
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`key`
|
||
]
|
||
[
|
||
The key of the element to find.
|
||
]
|
||
]
|
||
]
|
||
[heading See Also]
|
||
[link json.ref.boost__json__object.find `find`]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 object::if_contains (2 of 2 overloads)]
|
||
|
||
Return a pointer to the value if the key is found, or null.
|
||
[heading Synopsis]
|
||
```
|
||
value*
|
||
if_contains(
|
||
string_view key);
|
||
```
|
||
|
||
[heading Description]
|
||
This function searches for a value with the given key, and returns a pointer to it if found. Otherwise it returns null.
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
if( auto p = obj.if_contains( "key" ) )
|
||
std::cout << *p;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant on average, worst case linear in [link json.ref.boost__json__object.size `size()`].
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`key`
|
||
]
|
||
[
|
||
The key of the element to find.
|
||
]
|
||
]
|
||
]
|
||
[heading See Also]
|
||
[link json.ref.boost__json__object.find `find`]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:max_size object::max_size]
|
||
[indexterm2 max_size..object]
|
||
|
||
|
||
Return the maximum number of elements any object can hold.
|
||
[heading Synopsis]
|
||
```
|
||
static
|
||
constexpr std::size_t
|
||
max_size();
|
||
```
|
||
|
||
[heading Description]
|
||
The maximum is an implementation-defined number dependent on system or library implementation. This value is a theoretical limit; at runtime, the actual maximum size may be less due to resource limits.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__object_kind_t object_kind_t]
|
||
|
||
A tag type used to select a [link json.ref.boost__json__value `value`] constructor overload.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/kind.hpp]
|
||
|
||
```
|
||
struct object_kind_t
|
||
```
|
||
|
||
[heading Description]
|
||
The library provides the constant [link json.ref.boost__json__object_kind `object_kind`] which may be used to select the [link json.ref.boost__json__value `value`] constructor that creates an empty [link json.ref.boost__json__object `object`].
|
||
|
||
[heading See Also]
|
||
[link json.ref.boost__json__object_kind `object_kind`]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__parse_options parse_options]
|
||
|
||
Parser options.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/parse_options.hpp]
|
||
|
||
```
|
||
struct parse_options
|
||
```
|
||
|
||
[heading Data Members]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__parse_options.allow_comments allow_comments]]
|
||
]
|
||
[Non-standard extension option.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__parse_options.allow_invalid_utf8 allow_invalid_utf8]]
|
||
]
|
||
[Non-standard extension option.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__parse_options.allow_trailing_commas allow_trailing_commas]]
|
||
]
|
||
[Non-standard extension option.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__parse_options.max_depth max_depth]]
|
||
]
|
||
[Maximum nesting level of arrays and objects.
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
This structure is used for specifying maximum parsing depth, and whether to allow various non-standard extensions. Default-constructed options set maximum parsing depth to 32 and specify that only standard JSON is allowed,
|
||
|
||
[heading See Also]
|
||
[link json.ref.boost__json__basic_parser `basic_parser`], [link json.ref.boost__json__parser `parser`].
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
[section:max_depth parse_options::max_depth]
|
||
[indexterm2 max_depth..parse_options]
|
||
|
||
|
||
Maximum nesting level of arrays and objects.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t max_depth = 32;
|
||
```
|
||
|
||
[heading Description]
|
||
This specifies the maximum number of nested structures allowed while parsing a JSON. If this limit is exceeded during a parse, an error is returned.
|
||
|
||
[heading See Also]
|
||
[link json.ref.boost__json__basic_parser `basic_parser`], [link json.ref.boost__json__stream_parser `stream_parser`].
|
||
|
||
[endsect]
|
||
|
||
[section:allow_comments parse_options::allow_comments]
|
||
[indexterm2 allow_comments..parse_options]
|
||
|
||
|
||
Non-standard extension option.
|
||
[heading Synopsis]
|
||
```
|
||
bool allow_comments = false;
|
||
```
|
||
|
||
[heading Description]
|
||
Allow C and C++ style comments to appear anywhere that whitespace is permissible.
|
||
|
||
[heading See Also]
|
||
[link json.ref.boost__json__basic_parser `basic_parser`], [link json.ref.boost__json__stream_parser `stream_parser`].
|
||
|
||
[endsect]
|
||
|
||
[section:allow_trailing_commas parse_options::allow_trailing_commas]
|
||
[indexterm2 allow_trailing_commas..parse_options]
|
||
|
||
|
||
Non-standard extension option.
|
||
[heading Synopsis]
|
||
```
|
||
bool allow_trailing_commas = false;
|
||
```
|
||
|
||
[heading Description]
|
||
Allow a trailing comma to appear after the last element of any array or object.
|
||
|
||
[heading See Also]
|
||
[link json.ref.boost__json__basic_parser `basic_parser`], [link json.ref.boost__json__stream_parser `stream_parser`].
|
||
|
||
[endsect]
|
||
|
||
[section:allow_invalid_utf8 parse_options::allow_invalid_utf8]
|
||
[indexterm2 allow_invalid_utf8..parse_options]
|
||
|
||
|
||
Non-standard extension option.
|
||
[heading Synopsis]
|
||
```
|
||
bool allow_invalid_utf8 = false;
|
||
```
|
||
|
||
[heading Description]
|
||
Allow invalid UTF-8 sequnces to appear in keys and strings.
|
||
|
||
[heading Remarks]
|
||
This increases parsing performance.
|
||
[heading See Also]
|
||
[link json.ref.boost__json__basic_parser `basic_parser`], [link json.ref.boost__json__stream_parser `stream_parser`].
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__parser parser]
|
||
|
||
A DOM parser for JSON contained in a single buffer.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/parser.hpp]
|
||
|
||
```
|
||
class parser
|
||
```
|
||
|
||
[heading Member Functions]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__parser.operator_eq_ operator=]]
|
||
]
|
||
[Copy assignment (deleted)
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__parser.parser parser] [role silver \[constructor\]]]
|
||
]
|
||
[Copy constructor (deleted) [br][role silver —][br]Constructor.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__parser.release release]]
|
||
]
|
||
[Return the parsed JSON as a [link json.ref.boost__json__value `value`].
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__parser.reset reset]]
|
||
]
|
||
[Reset the parser for a new JSON.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__parser.write write]]
|
||
]
|
||
[Parse a buffer containing a complete JSON.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__parser.write_some write_some]]
|
||
]
|
||
[Parse a buffer containing a complete JSON.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__parser._parser ~parser] [role silver \[destructor\]]]
|
||
]
|
||
[Destructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
This class is used to parse a JSON contained in a single character buffer, into a [link json.ref.boost__json__value `value`] container.
|
||
|
||
[heading Usage]
|
||
|
||
To use the parser first construct it, then optionally call [link json.ref.boost__json__parser.reset `reset`] to specify a [link json.ref.boost__json__storage_ptr `storage_ptr`] to use for the resulting [link json.ref.boost__json__value `value`]. Then call [link json.ref.boost__json__parser.write `write`] to parse a character buffer containing a complete JSON. If the parse is successful, call [link json.ref.boost__json__parser.release `release`] to take ownership of the value:
|
||
```
|
||
parser p; // construct a parser
|
||
size_t n = p.write( "\[1,2,3\]" ); // parse a complete JSON
|
||
assert( n == 7 ); // all characters consumed
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
|
||
[heading Extra Data]
|
||
|
||
When the character buffer provided as input contains additional data that is not part of the complete JSON, an error is returned. The [link json.ref.boost__json__parser.write_some `write_some`] function is an alternative which allows the parse to finish early, without consuming all the characters in the buffer. This allows parsing of a buffer containing multiple individual JSONs or containing different protocol data:
|
||
```
|
||
parser p; // construct a parser
|
||
size_t n = p.write_some( "\[1,2,3\] null" ); // parse a complete JSON
|
||
assert( n == 8 ); // only some characters consumed
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
|
||
[heading Temporary Storage]
|
||
|
||
The parser may dynamically allocate temporary storage as needed to accommodate the nesting level of the JSON being parsed. Temporary storage is first obtained from an optional, caller-owned buffer specified upon construction. When that is exhausted, the next allocation uses the [link json.ref.boost__json__memory_resource `memory_resource`] passed to the constructor; if no such argument is specified, the default memory resource is used. Temporary storage is freed only when the parser is destroyed; The performance of parsing multiple JSONs may be improved by reusing the same parser instance.
|
||
|
||
|
||
It is important to note that the [link json.ref.boost__json__memory_resource `memory_resource`] supplied upon construction is used for temporary storage only, and not for allocating the elements which make up the parsed value. That other memory resource is optionally supplied in each call to [link json.ref.boost__json__parser.reset `reset`].
|
||
|
||
[heading Duplicate Keys]
|
||
|
||
If there are object elements with duplicate keys; that is, if multiple elements in an object have keys that compare equal, only the last equivalent element will be inserted.
|
||
|
||
[heading Non-Standard JSON]
|
||
|
||
The [link json.ref.boost__json__parse_options `parse_options`] structure optionally provided upon construction is used to customize some parameters of the parser, including which non-standard JSON extensions should be allowed. A default-constructed parse options allows only standard JSON.
|
||
|
||
[heading Thread Safety]
|
||
|
||
Distinct instances may be accessed concurrently. Non-const member functions of a shared instance may not be called concurrently with any other member functions of that instance.
|
||
|
||
[heading See Also]
|
||
[link json.ref.boost__json__parse `parse`], [link json.ref.boost__json__parse_options `parse_options`], [link json.ref.boost__json__stream_parser `stream_parser`].
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
[section:parser parser::parser]
|
||
[indexterm2 parser..parser]
|
||
|
||
|
||
Copy constructor (deleted)
|
||
```
|
||
``[link json.ref.boost__json__parser.parser.overload1 parser]``(
|
||
parser const&);
|
||
``[''''»''' [link json.ref.boost__json__parser.parser.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Constructor.
|
||
```
|
||
``[link json.ref.boost__json__parser.parser.overload2 parser]``(
|
||
storage_ptr sp,
|
||
parse_options const& opt,
|
||
unsigned char* buffer,
|
||
std::size_t size);
|
||
``[''''»''' [link json.ref.boost__json__parser.parser.overload2 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__parser.parser.overload3 parser]``();
|
||
``[''''»''' [link json.ref.boost__json__parser.parser.overload3 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__parser.parser.overload4 parser]``(
|
||
storage_ptr sp,
|
||
parse_options const& opt);
|
||
``[''''»''' [link json.ref.boost__json__parser.parser.overload4 `more...`]]``
|
||
|
||
explicit
|
||
``[link json.ref.boost__json__parser.parser.overload5 parser]``(
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__parser.parser.overload5 `more...`]]``
|
||
|
||
template<
|
||
std::size_t N>
|
||
``[link json.ref.boost__json__parser.parser.overload6 parser]``(
|
||
storage_ptr sp,
|
||
parse_options const& opt,
|
||
unsigned char(&) buffer \[N\]);
|
||
``[''''»''' [link json.ref.boost__json__parser.parser.overload6 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__parser.parser.overload7 parser]``(
|
||
storage_ptr sp,
|
||
parse_options const& opt,
|
||
std::byte* buffer,
|
||
std::size_t size);
|
||
``[''''»''' [link json.ref.boost__json__parser.parser.overload7 `more...`]]``
|
||
|
||
template<
|
||
std::size_t N>
|
||
``[link json.ref.boost__json__parser.parser.overload8 parser]``(
|
||
storage_ptr sp,
|
||
parse_options const& opt,
|
||
std::byte(&) buffer \[N\]);
|
||
``[''''»''' [link json.ref.boost__json__parser.parser.overload8 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 parser::parser (1 of 8 overloads)]
|
||
|
||
Copy constructor (deleted)
|
||
[heading Synopsis]
|
||
```
|
||
parser(
|
||
parser const&);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 parser::parser (2 of 8 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
parser(
|
||
storage_ptr sp,
|
||
parse_options const& opt,
|
||
unsigned char* buffer,
|
||
std::size_t size);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This constructs a new parser which first uses the caller-owned storage pointed to by `buffer` for temporary storage, falling back to the memory resource `sp` if needed. The parser will use the specified parsing options.
|
||
|
||
|
||
The parsed value will use the default memory resource for storage. To use a different resource, call [link json.ref.boost__json__parser.reset `reset`] after construction.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
The memory resource to use for temporary storage after `buffer` is exhausted.
|
||
]
|
||
]
|
||
[
|
||
[`opt`
|
||
]
|
||
[
|
||
The parsing options to use.
|
||
]
|
||
]
|
||
[
|
||
[`buffer`
|
||
]
|
||
[
|
||
A pointer to valid memory of at least `size` bytes for the parser to use for temporary storage. Ownership is not transferred, the caller is responsible for ensuring the lifetime of the memory pointed to by `buffer` extends until the parser is destroyed.
|
||
]
|
||
]
|
||
[
|
||
[`size`
|
||
]
|
||
[
|
||
The number of valid bytes in `buffer`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 parser::parser (3 of 8 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
parser();
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This constructs a new parser which uses the default memory resource for temporary storage, and accepts only strict JSON.
|
||
|
||
|
||
The parsed value will use the default memory resource for storage. To use a different resource, call [link json.ref.boost__json__parser.reset `reset`] after construction.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 parser::parser (4 of 8 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
parser(
|
||
storage_ptr sp,
|
||
parse_options const& opt);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This constructs a new parser which uses the specified memory resource for temporary storage, and is configured to use the specified parsing options.
|
||
|
||
|
||
The parsed value will use the default memory resource for storage. To use a different resource, call [link json.ref.boost__json__parser.reset `reset`] after construction.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
The memory resource to use for temporary storage.
|
||
]
|
||
]
|
||
[
|
||
[`opt`
|
||
]
|
||
[
|
||
The parsing options to use.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload5 parser::parser (5 of 8 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
parser(
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This constructs a new parser which uses the specified memory resource for temporary storage, and accepts only strict JSON.
|
||
|
||
|
||
The parsed value will use the default memory resource for storage. To use a different resource, call [link json.ref.boost__json__parser.reset `reset`] after construction.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
The memory resource to use for temporary storage.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload6 parser::parser (6 of 8 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
std::size_t N>
|
||
parser(
|
||
storage_ptr sp,
|
||
parse_options const& opt,
|
||
unsigned char(&) buffer \[N\]);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This constructs a new parser which first uses the caller-owned storage `buffer` for temporary storage, falling back to the memory resource `sp` if needed. The parser will use the specified parsing options.
|
||
|
||
|
||
The parsed value will use the default memory resource for storage. To use a different resource, call [link json.ref.boost__json__parser.reset `reset`] after construction.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
The memory resource to use for temporary storage after `buffer` is exhausted.
|
||
]
|
||
]
|
||
[
|
||
[`opt`
|
||
]
|
||
[
|
||
The parsing options to use.
|
||
]
|
||
]
|
||
[
|
||
[`buffer`
|
||
]
|
||
[
|
||
A buffer for the parser to use for temporary storage. Ownership is not transferred, the caller is responsible for ensuring the lifetime of `buffer` extends until the parser is destroyed.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload7 parser::parser (7 of 8 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
parser(
|
||
storage_ptr sp,
|
||
parse_options const& opt,
|
||
std::byte* buffer,
|
||
std::size_t size);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This constructs a new parser which first uses the caller-owned storage pointed to by `buffer` for temporary storage, falling back to the memory resource `sp` if needed. The parser will use the specified parsing options.
|
||
|
||
|
||
The parsed value will use the default memory resource for storage. To use a different resource, call [link json.ref.boost__json__parser.reset `reset`] after construction.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
The memory resource to use for temporary storage after `buffer` is exhausted.
|
||
]
|
||
]
|
||
[
|
||
[`opt`
|
||
]
|
||
[
|
||
The parsing options to use.
|
||
]
|
||
]
|
||
[
|
||
[`buffer`
|
||
]
|
||
[
|
||
A pointer to valid memory of at least `size` bytes for the parser to use for temporary storage. Ownership is not transferred, the caller is responsible for ensuring the lifetime of the memory pointed to by `buffer` extends until the parser is destroyed.
|
||
]
|
||
]
|
||
[
|
||
[`size`
|
||
]
|
||
[
|
||
The number of valid bytes in `buffer`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload8 parser::parser (8 of 8 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
std::size_t N>
|
||
parser(
|
||
storage_ptr sp,
|
||
parse_options const& opt,
|
||
std::byte(&) buffer \[N\]);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This constructs a new parser which first uses the caller-owned storage `buffer` for temporary storage, falling back to the memory resource `sp` if needed. The parser will use the specified parsing options.
|
||
|
||
|
||
The parsed value will use the default memory resource for storage. To use a different resource, call [link json.ref.boost__json__parser.reset `reset`] after construction.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
The memory resource to use for temporary storage after `buffer` is exhausted.
|
||
]
|
||
]
|
||
[
|
||
[`opt`
|
||
]
|
||
[
|
||
The parsing options to use.
|
||
]
|
||
]
|
||
[
|
||
[`buffer`
|
||
]
|
||
[
|
||
A buffer for the parser to use for temporary storage. Ownership is not transferred, the caller is responsible for ensuring the lifetime of `buffer` extends until the parser is destroyed.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:operator_eq_ parser::operator=]
|
||
[indexterm2 operator=..parser]
|
||
|
||
|
||
Copy assignment (deleted)
|
||
[heading Synopsis]
|
||
```
|
||
parser&
|
||
operator=(
|
||
parser const&);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:_parser parser::~parser]
|
||
[indexterm2 ~parser..parser]
|
||
|
||
|
||
Destructor.
|
||
[heading Synopsis]
|
||
```
|
||
~parser();
|
||
```
|
||
|
||
[heading Description]
|
||
All dynamically allocated memory, including any incomplete parsing results, is freed.
|
||
|
||
[heading Complexity]
|
||
Linear in the size of partial results
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:reset parser::reset]
|
||
[indexterm2 reset..parser]
|
||
|
||
|
||
Reset the parser for a new JSON.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
reset(
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
This function is used to reset the parser to prepare it for parsing a new complete JSON. Any previous partial results are destroyed.
|
||
|
||
[heading Complexity]
|
||
Constant or linear in the size of any previous partial parsing results.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use for the resulting [link json.ref.boost__json__value `value`]. The parser will acquire shared ownership.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:write_some parser::write_some]
|
||
[indexterm2 write_some..parser]
|
||
|
||
|
||
Parse a buffer containing a complete JSON.
|
||
```
|
||
std::size_t
|
||
``[link json.ref.boost__json__parser.write_some.overload1 write_some]``(
|
||
char const* data,
|
||
std::size_t size,
|
||
error_code& ec);
|
||
``[''''»''' [link json.ref.boost__json__parser.write_some.overload1 `more...`]]``
|
||
|
||
std::size_t
|
||
``[link json.ref.boost__json__parser.write_some.overload2 write_some]``(
|
||
char const* data,
|
||
std::size_t size);
|
||
``[''''»''' [link json.ref.boost__json__parser.write_some.overload2 `more...`]]``
|
||
|
||
std::size_t
|
||
``[link json.ref.boost__json__parser.write_some.overload3 write_some]``(
|
||
string_view s,
|
||
error_code& ec);
|
||
``[''''»''' [link json.ref.boost__json__parser.write_some.overload3 `more...`]]``
|
||
|
||
std::size_t
|
||
``[link json.ref.boost__json__parser.write_some.overload4 write_some]``(
|
||
string_view s);
|
||
``[''''»''' [link json.ref.boost__json__parser.write_some.overload4 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 parser::write_some (1 of 4 overloads)]
|
||
|
||
Parse a buffer containing a complete JSON.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
write_some(
|
||
char const* data,
|
||
std::size_t size,
|
||
error_code& ec);
|
||
```
|
||
|
||
[heading Description]
|
||
This function parses a complete JSON contained in the specified character buffer. Additional characters past the end of the complete JSON are ignored. The function returns the actual number of characters parsed, which may be less than the size of the input. This allows parsing of a buffer containing multiple individual JSONs or containing different protocol data:
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
parser p; // construct a parser
|
||
size_t n = p.write_some( "\[1,2,3\] null" ); // parse a complete JSON
|
||
assert( n == 8 ); // only some characters consumed
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
[heading Complexity]
|
||
Linear in `size`.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw. Upon error or exception, subsequent calls will fail until [link json.ref.boost__json__parser.reset `reset`] is called to parse a new JSON.
|
||
[heading Return Value]
|
||
The number of characters consumed from the buffer.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`data`
|
||
]
|
||
[
|
||
A pointer to a buffer of `size` characters to parse.
|
||
]
|
||
]
|
||
[
|
||
[`size`
|
||
]
|
||
[
|
||
The number of characters pointed to by `data`.
|
||
]
|
||
]
|
||
[
|
||
[`ec`
|
||
]
|
||
[
|
||
Set to the error, if any occurred.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 parser::write_some (2 of 4 overloads)]
|
||
|
||
Parse a buffer containing a complete JSON.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
write_some(
|
||
char const* data,
|
||
std::size_t size);
|
||
```
|
||
|
||
[heading Description]
|
||
This function parses a complete JSON contained in the specified character buffer. Additional characters past the end of the complete JSON are ignored. The function returns the actual number of characters parsed, which may be less than the size of the input. This allows parsing of a buffer containing multiple individual JSONs or containing different protocol data:
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
parser p; // construct a parser
|
||
size_t n = p.write_some( "\[1,2,3\] null" ); // parse a complete JSON
|
||
assert( n == 8 ); // only some characters consumed
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
[heading Complexity]
|
||
Linear in `size`.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw. Upon error or exception, subsequent calls will fail until [link json.ref.boost__json__parser.reset `reset`] is called to parse a new JSON.
|
||
[heading Return Value]
|
||
The number of characters consumed from the buffer.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`data`
|
||
]
|
||
[
|
||
A pointer to a buffer of `size` characters to parse.
|
||
]
|
||
]
|
||
[
|
||
[`size`
|
||
]
|
||
[
|
||
The number of characters pointed to by `data`.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`system_error`
|
||
]
|
||
[
|
||
Thrown on error.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 parser::write_some (3 of 4 overloads)]
|
||
|
||
Parse a buffer containing a complete JSON.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
write_some(
|
||
string_view s,
|
||
error_code& ec);
|
||
```
|
||
|
||
[heading Description]
|
||
This function parses a complete JSON contained in the specified character buffer. Additional characters past the end of the complete JSON are ignored. The function returns the actual number of characters parsed, which may be less than the size of the input. This allows parsing of a buffer containing multiple individual JSONs or containing different protocol data:
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
parser p; // construct a parser
|
||
size_t n = p.write_some( "\[1,2,3\] null" ); // parse a complete JSON
|
||
assert( n == 8 ); // only some characters consumed
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
[heading Complexity]
|
||
Linear in `size`.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw. Upon error or exception, subsequent calls will fail until [link json.ref.boost__json__parser.reset `reset`] is called to parse a new JSON.
|
||
[heading Return Value]
|
||
The number of characters consumed from the buffer.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The character string to parse.
|
||
]
|
||
]
|
||
[
|
||
[`ec`
|
||
]
|
||
[
|
||
Set to the error, if any occurred.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 parser::write_some (4 of 4 overloads)]
|
||
|
||
Parse a buffer containing a complete JSON.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
write_some(
|
||
string_view s);
|
||
```
|
||
|
||
[heading Description]
|
||
This function parses a complete JSON contained in the specified character buffer. Additional characters past the end of the complete JSON are ignored. The function returns the actual number of characters parsed, which may be less than the size of the input. This allows parsing of a buffer containing multiple individual JSONs or containing different protocol data:
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
parser p; // construct a parser
|
||
size_t n = p.write_some( "\[1,2,3\] null" ); // parse a complete JSON
|
||
assert( n == 8 ); // only some characters consumed
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
[heading Complexity]
|
||
Linear in `size`.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw. Upon error or exception, subsequent calls will fail until [link json.ref.boost__json__parser.reset `reset`] is called to parse a new JSON.
|
||
[heading Return Value]
|
||
The number of characters consumed from the buffer.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The character string to parse.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`system_error`
|
||
]
|
||
[
|
||
Thrown on error.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:write parser::write]
|
||
[indexterm2 write..parser]
|
||
|
||
|
||
Parse a buffer containing a complete JSON.
|
||
```
|
||
std::size_t
|
||
``[link json.ref.boost__json__parser.write.overload1 write]``(
|
||
char const* data,
|
||
std::size_t size,
|
||
error_code& ec);
|
||
``[''''»''' [link json.ref.boost__json__parser.write.overload1 `more...`]]``
|
||
|
||
std::size_t
|
||
``[link json.ref.boost__json__parser.write.overload2 write]``(
|
||
char const* data,
|
||
std::size_t size);
|
||
``[''''»''' [link json.ref.boost__json__parser.write.overload2 `more...`]]``
|
||
|
||
std::size_t
|
||
``[link json.ref.boost__json__parser.write.overload3 write]``(
|
||
string_view s,
|
||
error_code& ec);
|
||
``[''''»''' [link json.ref.boost__json__parser.write.overload3 `more...`]]``
|
||
|
||
std::size_t
|
||
``[link json.ref.boost__json__parser.write.overload4 write]``(
|
||
string_view s);
|
||
``[''''»''' [link json.ref.boost__json__parser.write.overload4 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 parser::write (1 of 4 overloads)]
|
||
|
||
Parse a buffer containing a complete JSON.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
write(
|
||
char const* data,
|
||
std::size_t size,
|
||
error_code& ec);
|
||
```
|
||
|
||
[heading Description]
|
||
This function parses a complete JSON contained in the specified character buffer. The entire buffer must be consumed; if there are additional characters past the end of the complete JSON, the parse fails and an error is returned.
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
parser p; // construct a parser
|
||
size_t n = p.write( "\[1,2,3\]" ); // parse a complete JSON
|
||
assert( n == 7 ); // all characters consumed
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
[heading Complexity]
|
||
Linear in `size`.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw. Upon error or exception, subsequent calls will fail until [link json.ref.boost__json__parser.reset `reset`] is called to parse a new JSON.
|
||
[heading Return Value]
|
||
The number of characters consumed from the buffer.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`data`
|
||
]
|
||
[
|
||
A pointer to a buffer of `size` characters to parse.
|
||
]
|
||
]
|
||
[
|
||
[`size`
|
||
]
|
||
[
|
||
The number of characters pointed to by `data`.
|
||
]
|
||
]
|
||
[
|
||
[`ec`
|
||
]
|
||
[
|
||
Set to the error, if any occurred.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 parser::write (2 of 4 overloads)]
|
||
|
||
Parse a buffer containing a complete JSON.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
write(
|
||
char const* data,
|
||
std::size_t size);
|
||
```
|
||
|
||
[heading Description]
|
||
This function parses a complete JSON contained in the specified character buffer. The entire buffer must be consumed; if there are additional characters past the end of the complete JSON, the parse fails and an error is returned.
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
parser p; // construct a parser
|
||
size_t n = p.write( "\[1,2,3\]" ); // parse a complete JSON
|
||
assert( n == 7 ); // all characters consumed
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
[heading Complexity]
|
||
Linear in `size`.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw. Upon error or exception, subsequent calls will fail until [link json.ref.boost__json__parser.reset `reset`] is called to parse a new JSON.
|
||
[heading Return Value]
|
||
The number of characters consumed from the buffer.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`data`
|
||
]
|
||
[
|
||
A pointer to a buffer of `size` characters to parse.
|
||
]
|
||
]
|
||
[
|
||
[`size`
|
||
]
|
||
[
|
||
The number of characters pointed to by `data`.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`system_error`
|
||
]
|
||
[
|
||
Thrown on error.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 parser::write (3 of 4 overloads)]
|
||
|
||
Parse a buffer containing a complete JSON.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
write(
|
||
string_view s,
|
||
error_code& ec);
|
||
```
|
||
|
||
[heading Description]
|
||
This function parses a complete JSON contained in the specified character buffer. The entire buffer must be consumed; if there are additional characters past the end of the complete JSON, the parse fails and an error is returned.
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
parser p; // construct a parser
|
||
size_t n = p.write( "\[1,2,3\]" ); // parse a complete JSON
|
||
assert( n == 7 ); // all characters consumed
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
[heading Complexity]
|
||
Linear in `size`.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw. Upon error or exception, subsequent calls will fail until [link json.ref.boost__json__parser.reset `reset`] is called to parse a new JSON.
|
||
[heading Return Value]
|
||
The number of characters consumed from the buffer.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The character string to parse.
|
||
]
|
||
]
|
||
[
|
||
[`ec`
|
||
]
|
||
[
|
||
Set to the error, if any occurred.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 parser::write (4 of 4 overloads)]
|
||
|
||
Parse a buffer containing a complete JSON.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
write(
|
||
string_view s);
|
||
```
|
||
|
||
[heading Description]
|
||
This function parses a complete JSON contained in the specified character buffer. The entire buffer must be consumed; if there are additional characters past the end of the complete JSON, the parse fails and an error is returned.
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
parser p; // construct a parser
|
||
size_t n = p.write( "\[1,2,3\]" ); // parse a complete JSON
|
||
assert( n == 7 ); // all characters consumed
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
[heading Complexity]
|
||
Linear in `size`.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw. Upon error or exception, subsequent calls will fail until [link json.ref.boost__json__parser.reset `reset`] is called to parse a new JSON.
|
||
[heading Return Value]
|
||
The number of characters consumed from the buffer.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The character string to parse.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`system_error`
|
||
]
|
||
[
|
||
Thrown on error.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:release parser::release]
|
||
[indexterm2 release..parser]
|
||
|
||
|
||
Return the parsed JSON as a [link json.ref.boost__json__value `value`].
|
||
[heading Synopsis]
|
||
```
|
||
value
|
||
release();
|
||
```
|
||
|
||
[heading Description]
|
||
This returns the parsed value, or throws an exception if the parsing is incomplete or failed. It is necessary to call [link json.ref.boost__json__parser.reset `reset`] after calling this function in order to parse another JSON.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Return Value]
|
||
The parsed value. Ownership of this value is transferred to the caller.
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`system_error`
|
||
]
|
||
[
|
||
Thrown on failure.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__pilfered pilfered]
|
||
|
||
Tag wrapper to specify pilfer-construction.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/pilfer.hpp]
|
||
|
||
```
|
||
template<
|
||
class T>
|
||
class pilfered
|
||
```
|
||
|
||
[heading Member Functions]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__pilfered.get get]]
|
||
]
|
||
[Return a reference to the pilferable object.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__pilfered.operator_arrow_ operator->]]
|
||
]
|
||
[Return a pointer to the pilferable object.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__pilfered.pilfered pilfered] [role silver \[constructor\]]]
|
||
]
|
||
[Constructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
This wrapper is used to specify a pilfer constructor overload.
|
||
|
||
[heading Example]
|
||
|
||
A pilfer constructor accepts a single argument of type [link json.ref.boost__json__pilfered `pilfered`] and throws nothing:
|
||
|
||
```
|
||
struct T
|
||
{
|
||
T( pilfered<T> ) noexcept;
|
||
};
|
||
```
|
||
|
||
|
||
[heading Remarks]
|
||
|
||
The constructor should not be marked explicit.
|
||
|
||
[heading See Also]
|
||
[link json.ref.boost__json__pilfer `pilfer`], [link json.ref.boost__json__is_pilfer_constructible `is_pilfer_constructible`], [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0308r0.html Valueless Variants Considered Harmful]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
[section:pilfered pilfered::pilfered]
|
||
[indexterm2 pilfered..pilfered]
|
||
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
constexpr
|
||
pilfered(
|
||
T&& t);
|
||
```
|
||
|
||
[heading Description]
|
||
Construct the wrapper from `t`.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`t`
|
||
]
|
||
[
|
||
The pilferable object. Ownership is not transferred.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:get pilfered::get]
|
||
[indexterm2 get..pilfered]
|
||
|
||
|
||
Return a reference to the pilferable object.
|
||
[heading Synopsis]
|
||
```
|
||
constexpr T&
|
||
get() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This returns a reference to the wrapped object.
|
||
|
||
[endsect]
|
||
|
||
[section:operator_arrow_ pilfered::operator->]
|
||
[indexterm2 operator->..pilfered]
|
||
|
||
|
||
Return a pointer to the pilferable object.
|
||
[heading Synopsis]
|
||
```
|
||
constexpr T*
|
||
operator->() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This returns a pointer to the wrapped object.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__polymorphic_allocator polymorphic_allocator]
|
||
|
||
The type of polymorphic allocator used by the library.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/memory_resource.hpp]
|
||
|
||
```
|
||
template<
|
||
class T>
|
||
class polymorphic_allocator
|
||
```
|
||
|
||
[heading Description]
|
||
This type alias is set depending on how the library is configured:
|
||
|
||
[heading Use with Boost]
|
||
|
||
If the macro `BOOST_JSON_STANDALONE` is not defined, this type will be an alias template for `boost::container::pmr::polymorphic_allocator`. Compiling a program using the library will require Boost, and a compiler conforming to C++11 or later.
|
||
|
||
[heading Use without Boost]
|
||
|
||
If the macro `BOOST_JSON_STANDALONE` is defined, this type will be an alias template for `std::pmr::polymorphic_allocator`. Compiling a program using the library will require only a compiler conforming to C++17 or later.
|
||
|
||
[heading See Also]
|
||
[@https://en.cppreference.com/w/cpp/memory/polymorphic_allocator https://en.cppreference.com/w/cpp/memory/polymorphic_allocator]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__serializer serializer]
|
||
|
||
A serializer for JSON.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/serializer.hpp]
|
||
|
||
```
|
||
class serializer
|
||
```
|
||
|
||
[heading Member Functions]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__serializer.done done]]
|
||
]
|
||
[Returns `true` if the serialization is complete.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__serializer.read read]]
|
||
]
|
||
[Read the next buffer of serialized JSON.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__serializer.reset reset]]
|
||
]
|
||
[Reset the serializer for a new element. [br][role silver —][br]Reset the serializer for a new string.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__serializer.serializer serializer] [role silver \[constructor\]]]
|
||
]
|
||
[Move constructor (deleted) [br][role silver —][br]Default constructor.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__serializer._serializer ~serializer] [role silver \[destructor\]]]
|
||
]
|
||
[Destructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
This class traverses an instance of a library type and emits serialized JSON text by filling in one or more caller-provided buffers. To use, declare a variable and call [link json.ref.boost__json__serializer.reset `reset`] with a pointer to the variable you want to serialize. Then call [link json.ref.boost__json__serializer.read `read`] over and over until [link json.ref.boost__json__serializer.done `done`] returns `true`.
|
||
|
||
[heading Example]
|
||
|
||
This demonstrates how the serializer may be used to print a JSON value to an output stream.
|
||
|
||
```
|
||
void print( std::ostream& os, value const& jv)
|
||
{
|
||
serializer sr;
|
||
sr.reset( &jv );
|
||
while( ! sr.done() )
|
||
{
|
||
char buf\[ 4000 \];
|
||
os << sr.read( buf );
|
||
}
|
||
}
|
||
```
|
||
|
||
|
||
[heading Thread Safety]
|
||
|
||
The same instance may not be accessed concurrently.
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
[section:reset serializer::reset]
|
||
[indexterm2 reset..serializer]
|
||
|
||
|
||
Reset the serializer for a new element.
|
||
```
|
||
void
|
||
``[link json.ref.boost__json__serializer.reset.overload1 reset]``(
|
||
value const* p);
|
||
``[''''»''' [link json.ref.boost__json__serializer.reset.overload1 `more...`]]``
|
||
|
||
void
|
||
``[link json.ref.boost__json__serializer.reset.overload2 reset]``(
|
||
array const* p);
|
||
``[''''»''' [link json.ref.boost__json__serializer.reset.overload2 `more...`]]``
|
||
|
||
void
|
||
``[link json.ref.boost__json__serializer.reset.overload3 reset]``(
|
||
object const* p);
|
||
``[''''»''' [link json.ref.boost__json__serializer.reset.overload3 `more...`]]``
|
||
|
||
void
|
||
``[link json.ref.boost__json__serializer.reset.overload4 reset]``(
|
||
string const* p);
|
||
``[''''»''' [link json.ref.boost__json__serializer.reset.overload4 `more...`]]``
|
||
```
|
||
|
||
|
||
Reset the serializer for a new string.
|
||
```
|
||
void
|
||
``[link json.ref.boost__json__serializer.reset.overload5 reset]``(
|
||
string_view sv);
|
||
``[''''»''' [link json.ref.boost__json__serializer.reset.overload5 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 serializer::reset (1 of 5 overloads)]
|
||
|
||
Reset the serializer for a new element.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
reset(
|
||
value const* p);
|
||
```
|
||
|
||
[heading Description]
|
||
This function prepares the serializer to emit a new serialized JSON representing `*p`. Any internally allocated memory is preserved and re-used for the new output.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`p`
|
||
]
|
||
[
|
||
A pointer to the element to serialize. Ownership is not transferred; The caller is responsible for ensuring that the lifetime of `*p` extends until it is no longer needed.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 serializer::reset (2 of 5 overloads)]
|
||
|
||
Reset the serializer for a new element.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
reset(
|
||
array const* p);
|
||
```
|
||
|
||
[heading Description]
|
||
This function prepares the serializer to emit a new serialized JSON representing `*p`. Any internally allocated memory is preserved and re-used for the new output.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`p`
|
||
]
|
||
[
|
||
A pointer to the element to serialize. Ownership is not transferred; The caller is responsible for ensuring that the lifetime of `*p` extends until it is no longer needed.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 serializer::reset (3 of 5 overloads)]
|
||
|
||
Reset the serializer for a new element.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
reset(
|
||
object const* p);
|
||
```
|
||
|
||
[heading Description]
|
||
This function prepares the serializer to emit a new serialized JSON representing `*p`. Any internally allocated memory is preserved and re-used for the new output.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`p`
|
||
]
|
||
[
|
||
A pointer to the element to serialize. Ownership is not transferred; The caller is responsible for ensuring that the lifetime of `*p` extends until it is no longer needed.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 serializer::reset (4 of 5 overloads)]
|
||
|
||
Reset the serializer for a new element.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
reset(
|
||
string const* p);
|
||
```
|
||
|
||
[heading Description]
|
||
This function prepares the serializer to emit a new serialized JSON representing `*p`. Any internally allocated memory is preserved and re-used for the new output.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`p`
|
||
]
|
||
[
|
||
A pointer to the element to serialize. Ownership is not transferred; The caller is responsible for ensuring that the lifetime of `*p` extends until it is no longer needed.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload5 serializer::reset (5 of 5 overloads)]
|
||
|
||
Reset the serializer for a new string.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
reset(
|
||
string_view sv);
|
||
```
|
||
|
||
[heading Description]
|
||
This function prepares the serializer to emit a new serialized JSON representing the string. Any internally allocated memory is preserved and re-used for the new output.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sv`
|
||
]
|
||
[
|
||
The characters representing the string. Ownership is not transferred; The caller is responsible for ensuring that the lifetime of the characters reference by `sv` extends until it is no longer needed.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:serializer serializer::serializer]
|
||
[indexterm2 serializer..serializer]
|
||
|
||
|
||
Move constructor (deleted)
|
||
```
|
||
``[link json.ref.boost__json__serializer.serializer.overload1 serializer]``(
|
||
serializer&&);
|
||
``[''''»''' [link json.ref.boost__json__serializer.serializer.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Default constructor.
|
||
```
|
||
``[link json.ref.boost__json__serializer.serializer.overload2 serializer]``();
|
||
``[''''»''' [link json.ref.boost__json__serializer.serializer.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 serializer::serializer (1 of 2 overloads)]
|
||
|
||
Move constructor (deleted)
|
||
[heading Synopsis]
|
||
```
|
||
serializer(
|
||
serializer&&);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 serializer::serializer (2 of 2 overloads)]
|
||
|
||
Default constructor.
|
||
[heading Synopsis]
|
||
```
|
||
serializer();
|
||
```
|
||
|
||
[heading Description]
|
||
This constructs a serializer with no value. The value may be set later by calling [link json.ref.boost__json__serializer.reset `reset`]. If serialization is attempted with no value, the output is as if a null value is serialized.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:_serializer serializer::~serializer]
|
||
[indexterm2 ~serializer..serializer]
|
||
|
||
|
||
Destructor.
|
||
[heading Synopsis]
|
||
```
|
||
~serializer();
|
||
```
|
||
|
||
[heading Description]
|
||
All temporary storage is deallocated.
|
||
|
||
[heading Complexity]
|
||
Constant
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:done serializer::done]
|
||
[indexterm2 done..serializer]
|
||
|
||
|
||
Returns `true` if the serialization is complete.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
done() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns `true` when all of the characters in the serialized representation of the value have been read.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:read serializer::read]
|
||
[indexterm2 read..serializer]
|
||
|
||
|
||
Read the next buffer of serialized JSON.
|
||
```
|
||
string_view
|
||
``[link json.ref.boost__json__serializer.read.overload1 read]``(
|
||
char* dest,
|
||
std::size_t size);
|
||
``[''''»''' [link json.ref.boost__json__serializer.read.overload1 `more...`]]``
|
||
|
||
template<
|
||
std::size_t N>
|
||
string_view
|
||
``[link json.ref.boost__json__serializer.read.overload2 read]``(
|
||
char(&) dest \[N\]);
|
||
``[''''»''' [link json.ref.boost__json__serializer.read.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 serializer::read (1 of 2 overloads)]
|
||
|
||
Read the next buffer of serialized JSON.
|
||
[heading Synopsis]
|
||
```
|
||
string_view
|
||
read(
|
||
char* dest,
|
||
std::size_t size);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This function attempts to fill the caller provided buffer starting at `dest` with up to `size` characters of the serialized JSON that represents the value. If the buffer is not large enough, multiple calls may be required.
|
||
|
||
|
||
If serialization completes during this call; that is, that all of the characters belonging to the serialized value have been written to caller-provided buffers, the function [link json.ref.boost__json__serializer.done `done`] will return `true`.
|
||
|
||
[heading Preconditions]
|
||
`this->done() == true`
|
||
[heading Complexity]
|
||
Linear in `size`.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Return Value]
|
||
A [link json.ref.boost__json__string_view `string_view`] containing the characters written, which may be less than `size`.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`dest`
|
||
]
|
||
[
|
||
A pointer to valid memory of at least `size` bytes.
|
||
]
|
||
]
|
||
[
|
||
[`size`
|
||
]
|
||
[
|
||
The maximum number of characters to write to the memory pointed to by `dest`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 serializer::read (2 of 2 overloads)]
|
||
|
||
Read the next buffer of serialized JSON.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
std::size_t N>
|
||
string_view
|
||
read(
|
||
char(&) dest \[N\]);
|
||
```
|
||
|
||
[heading Description]
|
||
This function allows reading into a character array, with a deduced maximum size.
|
||
|
||
[heading Preconditions]
|
||
`this->done() == true`
|
||
[heading Effects]
|
||
|
||
```
|
||
return this->read( dest, N );
|
||
```
|
||
|
||
[heading Complexity]
|
||
Linear in `N`.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Return Value]
|
||
A [link json.ref.boost__json__string_view `string_view`] containing the characters written, which may be less than `size`.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`dest`
|
||
]
|
||
[
|
||
The character array to write to.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__static_resource static_resource]
|
||
|
||
A resource using a caller-owned buffer, with a trivial deallocate.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/static_resource.hpp]
|
||
|
||
```
|
||
class static_resource :
|
||
public memory_resource
|
||
```
|
||
|
||
[heading Member Functions]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__static_resource.operator_eq_ operator=]]
|
||
]
|
||
[Copy assignment (deleted)
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__static_resource.release release]]
|
||
]
|
||
[Release all allocated memory.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__static_resource.static_resource static_resource] [role silver \[constructor\]]]
|
||
]
|
||
[Constructor. [br][role silver —][br]Copy constructor (deleted)
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__static_resource._static_resource ~static_resource] [role silver \[destructor\]]]
|
||
]
|
||
[Destructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
|
||
This memory resource is a special-purpose resource that releases allocated memory only when the resource is destroyed (or when [link json.ref.boost__json__static_resource.release `release`] is called). It has a trivial deallocate function; that is, the metafunction [link json.ref.boost__json__is_deallocate_trivial `is_deallocate_trivial`] returns `true`.
|
||
|
||
|
||
The resource is constructed from a caller-owned buffer from which subsequent calls to allocate are apportioned. When a memory request cannot be satisfied from the free bytes remaining in the buffer, the allocation request fails with the exception `std::bad_alloc`.
|
||
|
||
|
||
[heading Example]
|
||
|
||
This parses a JSON into a value which uses a local stack buffer, then prints the result.
|
||
|
||
```
|
||
unsigned char buf\[ 4000 \];
|
||
static_resource mr( buf );
|
||
|
||
// Parse the string, using our memory resource
|
||
value const jv = parse( "\[1,2,3\]", &mr );
|
||
|
||
// Print the JSON
|
||
std::cout << jv;
|
||
```
|
||
|
||
|
||
[heading Thread Safety]
|
||
Members of the same instance may not be called concurrently.
|
||
[heading See Also]
|
||
[@https://en.wikipedia.org/wiki/Region-based_memory_management https://en.wikipedia.org/wiki/Region-based_memory_management]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
[section:static_resource static_resource::static_resource]
|
||
[indexterm2 static_resource..static_resource]
|
||
|
||
|
||
Constructor.
|
||
```
|
||
``[link json.ref.boost__json__static_resource.static_resource.overload1 static_resource]``(
|
||
unsigned char* buffer,
|
||
std::size_t size);
|
||
``[''''»''' [link json.ref.boost__json__static_resource.static_resource.overload1 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__static_resource.static_resource.overload2 static_resource]``(
|
||
std::byte* buffer,
|
||
std::size_t size);
|
||
``[''''»''' [link json.ref.boost__json__static_resource.static_resource.overload2 `more...`]]``
|
||
|
||
template<
|
||
std::size_t N>
|
||
explicit
|
||
``[link json.ref.boost__json__static_resource.static_resource.overload3 static_resource]``(
|
||
unsigned char(&) buffer \[N\]);
|
||
``[''''»''' [link json.ref.boost__json__static_resource.static_resource.overload3 `more...`]]``
|
||
|
||
template<
|
||
std::size_t N>
|
||
explicit
|
||
``[link json.ref.boost__json__static_resource.static_resource.overload4 static_resource]``(
|
||
std::byte(&) buffer \[N\]);
|
||
``[''''»''' [link json.ref.boost__json__static_resource.static_resource.overload4 `more...`]]``
|
||
```
|
||
|
||
|
||
Copy constructor (deleted)
|
||
```
|
||
``[link json.ref.boost__json__static_resource.static_resource.overload5 static_resource]``(
|
||
static_resource const&);
|
||
``[''''»''' [link json.ref.boost__json__static_resource.static_resource.overload5 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 static_resource::static_resource (1 of 5 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
static_resource(
|
||
unsigned char* buffer,
|
||
std::size_t size);
|
||
```
|
||
|
||
[heading Description]
|
||
This constructs the resource to use the specified buffer for subsequent calls to allocate. When the buffer is exhausted, allocate will throw `std::bad_alloc`.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`buffer`
|
||
]
|
||
[
|
||
The buffer to use. Ownership is not transferred; the caller is responsible for ensuring that the lifetime of the buffer extends until the resource is destroyed.
|
||
]
|
||
]
|
||
[
|
||
[`size`
|
||
]
|
||
[
|
||
The number of valid bytes pointed to by `buffer`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 static_resource::static_resource (2 of 5 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
static_resource(
|
||
std::byte* buffer,
|
||
std::size_t size);
|
||
```
|
||
|
||
[heading Description]
|
||
This constructs the resource to use the specified buffer for subsequent calls to allocate. When the buffer is exhausted, allocate will throw `std::bad_alloc`.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`buffer`
|
||
]
|
||
[
|
||
The buffer to use. Ownership is not transferred; the caller is responsible for ensuring that the lifetime of the buffer extends until the resource is destroyed.
|
||
]
|
||
]
|
||
[
|
||
[`size`
|
||
]
|
||
[
|
||
The number of valid bytes pointed to by `buffer`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 static_resource::static_resource (3 of 5 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
std::size_t N>
|
||
static_resource(
|
||
unsigned char(&) buffer \[N\]);
|
||
```
|
||
|
||
[heading Description]
|
||
This constructs the resource to use the specified buffer for subsequent calls to allocate. When the buffer is exhausted, allocate will throw `std::bad_alloc`.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`buffer`
|
||
]
|
||
[
|
||
The buffer to use. Ownership is not transferred; the caller is responsible for ensuring that the lifetime of the buffer extends until the resource is destroyed.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 static_resource::static_resource (4 of 5 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
std::size_t N>
|
||
static_resource(
|
||
std::byte(&) buffer \[N\]);
|
||
```
|
||
|
||
[heading Description]
|
||
This constructs the resource to use the specified buffer for subsequent calls to allocate. When the buffer is exhausted, allocate will throw `std::bad_alloc`.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`buffer`
|
||
]
|
||
[
|
||
The buffer to use. Ownership is not transferred; the caller is responsible for ensuring that the lifetime of the buffer extends until the resource is destroyed.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload5 static_resource::static_resource (5 of 5 overloads)]
|
||
|
||
Copy constructor (deleted)
|
||
[heading Synopsis]
|
||
```
|
||
static_resource(
|
||
static_resource const&);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:operator_eq_ static_resource::operator=]
|
||
[indexterm2 operator=..static_resource]
|
||
|
||
|
||
Copy assignment (deleted)
|
||
[heading Synopsis]
|
||
```
|
||
static_resource&
|
||
operator=(
|
||
static_resource const&);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:_static_resource static_resource::~static_resource]
|
||
[indexterm2 ~static_resource..static_resource]
|
||
|
||
|
||
Destructor.
|
||
[heading Synopsis]
|
||
```
|
||
~static_resource();
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:release static_resource::release]
|
||
[indexterm2 release..static_resource]
|
||
|
||
|
||
Release all allocated memory.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
release();
|
||
```
|
||
|
||
[heading Description]
|
||
This function resets the buffer provided upon construction so that all of the valid bytes are available for subsequent allocation.
|
||
|
||
[heading Complexity]
|
||
Constant
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__storage_ptr storage_ptr]
|
||
|
||
A smart pointer to a [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/storage_ptr.hpp]
|
||
|
||
```
|
||
class storage_ptr
|
||
```
|
||
|
||
[heading Member Functions]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__storage_ptr.get get]]
|
||
]
|
||
[Return a pointer to the memory resource.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__storage_ptr.is_deallocate_trivial is_deallocate_trivial]]
|
||
]
|
||
[Return `true` if calling `deallocate` on the memory resource has no effect.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__storage_ptr.is_not_shared_and_deallocate_is_trivial is_not_shared_and_deallocate_is_trivial]]
|
||
]
|
||
[Return `true` if ownership of the memory resource is not shared and deallocate is trivial.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__storage_ptr.is_shared is_shared]]
|
||
]
|
||
[Return `true` if ownership of the memory resource is shared.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__storage_ptr.operator__star_ operator *]]
|
||
]
|
||
[Return a reference to the memory resource.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__storage_ptr.operator_arrow_ operator->]]
|
||
]
|
||
[Return a pointer to the memory resource.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__storage_ptr.operator_eq_ operator=]]
|
||
]
|
||
[Move assignment. [br][role silver —][br]Copy assignment.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__storage_ptr.storage_ptr storage_ptr] [role silver \[constructor\]]]
|
||
]
|
||
[Constructor. [br][role silver —][br]Move constructor. [br][role silver —][br]Copy constructor.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__storage_ptr._storage_ptr ~storage_ptr] [role silver \[destructor\]]]
|
||
]
|
||
[Destructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Friends]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__storage_ptr.make_shared_resource make_shared_resource]]
|
||
]
|
||
[Return shared ownership of a new, dynamically allocated memory resource.
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
This container is used to hold a pointer to a memory resource. The pointed-to resource is always valid; default-constructed pointers use the default memory resource, which calls into the standard global system heap. Depending on the means of construction, the ownership will be either:
|
||
|
||
* Non-owning, when constructing from a raw pointer to [link json.ref.boost__json__memory_resource `memory_resource`] or from a [link json.ref.boost__json__polymorphic_allocator `polymorphic_allocator`]. In this case the caller is responsible for ensuring that the lifetime of the memory resource extends until there are no more calls to allocate or deallocate.
|
||
|
||
* Owning, when constructing using the function [link json.ref.boost__json__storage_ptr.make_shared_resource `make_shared_resource`]. In this case ownership is shared; the lifetime of the memory resource extends until the last copy of the [link json.ref.boost__json__storage_ptr `storage_ptr`] is destroyed.
|
||
|
||
[heading Examples]
|
||
|
||
These statements create a memory resource on the stack and construct a pointer from it without taking ownership:
|
||
```
|
||
monotonic_resource mr; // Create our memory resource on the stack
|
||
storage_ptr sp( &mr ); // Construct a non-owning pointer to the resource
|
||
```
|
||
|
||
|
||
This function creates a pointer to a memory resource using shared ownership and returns it. The lifetime of the memory resource extends until the last copy of the pointer is destroyed:
|
||
```
|
||
// Create a counted memory resource and return it
|
||
storage_ptr make_storage()
|
||
{
|
||
return make_shared_resource< monotonic_resource >();
|
||
}
|
||
```
|
||
|
||
|
||
[heading Thread Safety]
|
||
|
||
Instances of this type provide the default level of thread safety for all C++ objects. Specifically, it conforms to [@http://eel.is/c++draft/res.on.data.races 16.4.6.10 Data race avoidance].
|
||
|
||
[heading See Also]
|
||
[link json.ref.boost__json__storage_ptr.make_shared_resource `make_shared_resource`], [link json.ref.boost__json__memory_resource `memory_resource`], [link json.ref.boost__json__polymorphic_allocator `polymorphic_allocator`]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
[section:_storage_ptr storage_ptr::~storage_ptr]
|
||
[indexterm2 ~storage_ptr..storage_ptr]
|
||
|
||
|
||
Destructor.
|
||
[heading Synopsis]
|
||
```
|
||
~storage_ptr();
|
||
```
|
||
|
||
[heading Description]
|
||
If the pointer has shared ownership of the resource, the shared ownership is released. If this is the last owned copy, the memory resource is destroyed.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:storage_ptr storage_ptr::storage_ptr]
|
||
[indexterm2 storage_ptr..storage_ptr]
|
||
|
||
|
||
Constructor.
|
||
```
|
||
``[link json.ref.boost__json__storage_ptr.storage_ptr.overload1 storage_ptr]``();
|
||
``[''''»''' [link json.ref.boost__json__storage_ptr.storage_ptr.overload1 `more...`]]``
|
||
|
||
template<
|
||
class T>
|
||
``[link json.ref.boost__json__storage_ptr.storage_ptr.overload2 storage_ptr]``(
|
||
T* r);
|
||
``[''''»''' [link json.ref.boost__json__storage_ptr.storage_ptr.overload2 `more...`]]``
|
||
|
||
template<
|
||
class T>
|
||
``[link json.ref.boost__json__storage_ptr.storage_ptr.overload3 storage_ptr]``(
|
||
polymorphic_allocator< T > const& alloc);
|
||
``[''''»''' [link json.ref.boost__json__storage_ptr.storage_ptr.overload3 `more...`]]``
|
||
```
|
||
|
||
|
||
Move constructor.
|
||
```
|
||
``[link json.ref.boost__json__storage_ptr.storage_ptr.overload4 storage_ptr]``(
|
||
storage_ptr&& other);
|
||
``[''''»''' [link json.ref.boost__json__storage_ptr.storage_ptr.overload4 `more...`]]``
|
||
```
|
||
|
||
|
||
Copy constructor.
|
||
```
|
||
``[link json.ref.boost__json__storage_ptr.storage_ptr.overload5 storage_ptr]``(
|
||
storage_ptr const& other);
|
||
``[''''»''' [link json.ref.boost__json__storage_ptr.storage_ptr.overload5 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 storage_ptr::storage_ptr (1 of 5 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
storage_ptr();
|
||
```
|
||
|
||
[heading Description]
|
||
This constructs a non-owning pointer that refers to the default memory resource, which uses the standard global system heap to allocate and free memory.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 storage_ptr::storage_ptr (2 of 5 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class T>
|
||
storage_ptr(
|
||
T* r);
|
||
```
|
||
|
||
[heading Description]
|
||
This constructs a non-owning pointer that points to the memory resource `r`. The caller is responsible for maintaining the lifetime of the pointed-to [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
|
||
[heading Constraints]
|
||
|
||
```
|
||
std::is_convertible< T*, memory_resource* >::value == true
|
||
```
|
||
|
||
[heading Preconditions]
|
||
|
||
```
|
||
r != nullptr
|
||
```
|
||
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`r`
|
||
]
|
||
[
|
||
A pointer to the memory resource to use. This may not be null.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 storage_ptr::storage_ptr (3 of 5 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class T>
|
||
storage_ptr(
|
||
polymorphic_allocator< T > const& alloc);
|
||
```
|
||
|
||
[heading Description]
|
||
This constructs a non-owning pointer that points to the same memory resource as `alloc`, obtained by calling `alloc.resource()`. The caller is responsible for maintaining the lifetime of the pointed-to [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
|
||
[heading Constraints]
|
||
|
||
```
|
||
std::is_convertible< T*, memory_resource* >::value == true
|
||
```
|
||
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`alloc`
|
||
]
|
||
[
|
||
A [link json.ref.boost__json__polymorphic_allocator `polymorphic_allocator`] to construct from.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 storage_ptr::storage_ptr (4 of 5 overloads)]
|
||
|
||
Move constructor.
|
||
[heading Synopsis]
|
||
```
|
||
storage_ptr(
|
||
storage_ptr&& other);
|
||
```
|
||
|
||
[heading Description]
|
||
This function constructs a pointer that points to the same memory resource as `other`, with the same ownership:
|
||
|
||
* If `other` is non-owning, then `*this` will be be non-owning.
|
||
|
||
* If `other` has shared ownership, then ownership will be transferred to `*this`.
|
||
|
||
After construction, `other` will point to the default memory resource.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The pointer to construct from.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload5 storage_ptr::storage_ptr (5 of 5 overloads)]
|
||
|
||
Copy constructor.
|
||
[heading Synopsis]
|
||
```
|
||
storage_ptr(
|
||
storage_ptr const& other);
|
||
```
|
||
|
||
[heading Description]
|
||
This function constructs a pointer that points to the same memory resource as `other`, with the same ownership:
|
||
|
||
* If `other` is non-owning, then `*this` will be be non-owning.
|
||
|
||
* If `other` has shared ownership, then `*this` will acquire shared ownership.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The pointer to construct from.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:operator_eq_ storage_ptr::operator=]
|
||
[indexterm2 operator=..storage_ptr]
|
||
|
||
|
||
Move assignment.
|
||
```
|
||
storage_ptr&
|
||
``[link json.ref.boost__json__storage_ptr.operator_eq_.overload1 operator=]``(
|
||
storage_ptr&& other);
|
||
``[''''»''' [link json.ref.boost__json__storage_ptr.operator_eq_.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Copy assignment.
|
||
```
|
||
storage_ptr&
|
||
``[link json.ref.boost__json__storage_ptr.operator_eq_.overload2 operator=]``(
|
||
storage_ptr const& other);
|
||
``[''''»''' [link json.ref.boost__json__storage_ptr.operator_eq_.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 storage_ptr::operator= (1 of 2 overloads)]
|
||
|
||
Move assignment.
|
||
[heading Synopsis]
|
||
```
|
||
storage_ptr&
|
||
operator=(
|
||
storage_ptr&& other);
|
||
```
|
||
|
||
[heading Description]
|
||
This function assigns a pointer that points to the same memory resource as `other`, with the same ownership:
|
||
|
||
* If `other` is non-owning, then `*this` will be be non-owning.
|
||
|
||
* If `other` has shared ownership, then ownership will be transferred to `*this`.
|
||
|
||
After assignment, `other` will point to the default memory resource. If `*this` previously had shared ownership, it is released before the function returns.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The storage pointer to move.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 storage_ptr::operator= (2 of 2 overloads)]
|
||
|
||
Copy assignment.
|
||
[heading Synopsis]
|
||
```
|
||
storage_ptr&
|
||
operator=(
|
||
storage_ptr const& other);
|
||
```
|
||
|
||
[heading Description]
|
||
This function assigns a pointer that points to the same memory resource as `other`, with the same ownership:
|
||
|
||
* If `other` is non-owning, then `*this` will be be non-owning.
|
||
|
||
* If `other` has shared ownership, then `*this` will acquire shared ownership.
|
||
|
||
If `*this` previously had shared ownership, it is released before the function returns.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The storage pointer to copy.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:is_shared storage_ptr::is_shared]
|
||
[indexterm2 is_shared..storage_ptr]
|
||
|
||
|
||
Return `true` if ownership of the memory resource is shared.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
is_shared() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns true for memory resources created using [link json.ref.boost__json__storage_ptr.make_shared_resource `make_shared_resource`].
|
||
|
||
[endsect]
|
||
|
||
[section:is_deallocate_trivial storage_ptr::is_deallocate_trivial]
|
||
[indexterm2 is_deallocate_trivial..storage_ptr]
|
||
|
||
|
||
Return `true` if calling `deallocate` on the memory resource has no effect.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
is_deallocate_trivial() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function is used to determine if the deallocate function of the pointed to memory resource is trivial. The value of [link json.ref.boost__json__is_deallocate_trivial `is_deallocate_trivial`] is evaluated and saved when the memory resource is constructed and the type is known, before the type is erased.
|
||
|
||
[endsect]
|
||
|
||
[section:is_not_shared_and_deallocate_is_trivial storage_ptr::is_not_shared_and_deallocate_is_trivial]
|
||
[indexterm2 is_not_shared_and_deallocate_is_trivial..storage_ptr]
|
||
|
||
|
||
Return `true` if ownership of the memory resource is not shared and deallocate is trivial.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
is_not_shared_and_deallocate_is_trivial() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function is used to determine if calls to deallocate can effectively be skipped.
|
||
|
||
[heading Effects]
|
||
Returns `! this->is_shared() && this->is_deallocate_trivial()`
|
||
|
||
[endsect]
|
||
|
||
[section:get storage_ptr::get]
|
||
[indexterm2 get..storage_ptr]
|
||
|
||
|
||
Return a pointer to the memory resource.
|
||
[heading Synopsis]
|
||
```
|
||
memory_resource*
|
||
get() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns a pointer to the referenced [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:operator_arrow_ storage_ptr::operator->]
|
||
[indexterm2 operator->..storage_ptr]
|
||
|
||
|
||
Return a pointer to the memory resource.
|
||
[heading Synopsis]
|
||
```
|
||
memory_resource*
|
||
operator->() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns a pointer to the referenced [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:operator__star_ storage_ptr::operator *]
|
||
[indexterm2 operator *..storage_ptr]
|
||
|
||
|
||
Return a reference to the memory resource.
|
||
[heading Synopsis]
|
||
```
|
||
memory_resource&
|
||
operator *() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns a reference to the pointed-to [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[heading Exception Safety]
|
||
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:make_shared_resource storage_ptr::make_shared_resource]
|
||
[indexterm2 make_shared_resource..storage_ptr]
|
||
|
||
|
||
Return shared ownership of a new, dynamically allocated memory resource.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/storage_ptr.hpp]
|
||
|
||
```
|
||
template<
|
||
class U,
|
||
class... Args>
|
||
friend storage_ptr
|
||
make_shared_resource(
|
||
Args&&... args);
|
||
```
|
||
|
||
[heading Description]
|
||
This function dynamically allocates a new memory resource as if by `operator new` that uses shared ownership. The lifetime of the memory resource will be extended until the last [link json.ref.boost__json__storage_ptr `storage_ptr`] which points to it is destroyed.
|
||
|
||
[heading Mandates]
|
||
|
||
```
|
||
std::is_base_of< memory_resource, T >::value == true
|
||
```
|
||
|
||
[heading Complexity]
|
||
Same as `new T( std::forward<Args>(args)... )`.
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Template Parameters]
|
||
[table [[Type][Description]]
|
||
[
|
||
[`T`
|
||
]
|
||
[
|
||
The type of memory resource to create.
|
||
]
|
||
]
|
||
]
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`args`
|
||
]
|
||
[
|
||
Parameters forwarded to the constructor of `T`.
|
||
]
|
||
]
|
||
]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__stream_parser stream_parser]
|
||
|
||
A DOM parser for JSON contained in multiple buffers.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/stream_parser.hpp]
|
||
|
||
```
|
||
class stream_parser
|
||
```
|
||
|
||
[heading Member Functions]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__stream_parser.done done]]
|
||
]
|
||
[Return true if a complete JSON has been parsed.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__stream_parser.finish finish]]
|
||
]
|
||
[Indicate the end of JSON input.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__stream_parser.operator_eq_ operator=]]
|
||
]
|
||
[Copy assignment (deleted)
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__stream_parser.release release]]
|
||
]
|
||
[Return the parsed JSON as a [link json.ref.boost__json__value `value`].
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__stream_parser.reset reset]]
|
||
]
|
||
[Reset the parser for a new JSON.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__stream_parser.stream_parser stream_parser] [role silver \[constructor\]]]
|
||
]
|
||
[Copy constructor (deleted) [br][role silver —][br]Constructor.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__stream_parser.write write]]
|
||
]
|
||
[Parse a buffer containing all or part of a complete JSON.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__stream_parser.write_some write_some]]
|
||
]
|
||
[Parse a buffer containing all or part of a complete JSON.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__stream_parser._stream_parser ~stream_parser] [role silver \[destructor\]]]
|
||
]
|
||
[Destructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
This class is used to parse a JSON contained in a series of one or more character buffers, into a [link json.ref.boost__json__value `value`] container. It implements a [@https://en.wikipedia.org/wiki/Streaming_algorithm ['streaming algorithm]], allowing these parsing strategies:
|
||
|
||
* Parse a JSON file a piece at a time.
|
||
|
||
* Parse incoming JSON as it arrives, one buffer at a time.
|
||
|
||
* Parse with bounded resource consumption per cycle.
|
||
|
||
[heading Usage]
|
||
|
||
To use the parser first construct it, then optionally call [link json.ref.boost__json__stream_parser.reset `reset`] to specify a [link json.ref.boost__json__storage_ptr `storage_ptr`] to use for the resulting [link json.ref.boost__json__value `value`]. Then call [link json.ref.boost__json__stream_parser.write `write`] one or more times to parse a single, complete JSON. Call [link json.ref.boost__json__stream_parser.done `done`] to determine if the parse has completed. To indicate there are no more buffers, call [link json.ref.boost__json__stream_parser.finish `finish`]. If the parse is successful, call [link json.ref.boost__json__stream_parser.release `release`] to take ownership of the value:
|
||
|
||
```
|
||
stream_parser p; // construct a parser
|
||
p.write( "\[1,2" ); // parse some of a JSON
|
||
p.write( ",3,4\]" ); // parse the rest of the JSON
|
||
assert( p.done() ); // we have a complete JSON
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
|
||
[heading Extra Data]
|
||
|
||
When the character buffer provided as input contains additional data that is not part of the complete JSON, an error is returned. The [link json.ref.boost__json__stream_parser.write_some `write_some`] function is an alternative which allows the parse to finish early, without consuming all the characters in the buffer. This allows parsing of a buffer containing multiple individual JSONs or containing different protocol data:
|
||
```
|
||
stream_parser p; // construct a parser
|
||
std::size_t n; // number of characters used
|
||
n = p.write_some( "\[1,2" ); // parse some of a JSON
|
||
assert( n == 4 ); // all characters consumed
|
||
n = p.write_some( ",3,4\] null" ); // parse the remainder of the JSON
|
||
assert( n == 6 ); // only some characters consumed
|
||
assert( p.done() ); // we have a complete JSON
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
|
||
[heading Temporary Storage]
|
||
|
||
The parser may dynamically allocate temporary storage as needed to accommodate the nesting level of the JSON being parsed. Temporary storage is first obtained from an optional, caller-owned buffer specified upon construction. When that is exhausted, the next allocation uses the [link json.ref.boost__json__memory_resource `memory_resource`] passed to the constructor; if no such argument is specified, the default memory resource is used. Temporary storage is freed only when the parser is destroyed; The performance of parsing multiple JSONs may be improved by reusing the same parser instance.
|
||
|
||
|
||
It is important to note that the [link json.ref.boost__json__memory_resource `memory_resource`] supplied upon construction is used for temporary storage only, and not for allocating the elements which make up the parsed value. That other memory resource is optionally supplied in each call to [link json.ref.boost__json__stream_parser.reset `reset`].
|
||
|
||
[heading Duplicate Keys]
|
||
|
||
If there are object elements with duplicate keys; that is, if multiple elements in an object have keys that compare equal, only the last equivalent element will be inserted.
|
||
|
||
[heading Non-Standard JSON]
|
||
|
||
The [link json.ref.boost__json__parse_options `parse_options`] structure optionally provided upon construction is used to customize some parameters of the parser, including which non-standard JSON extensions should be allowed. A default-constructed parse options allows only standard JSON.
|
||
|
||
[heading Thread Safety]
|
||
|
||
Distinct instances may be accessed concurrently. Non-const member functions of a shared instance may not be called concurrently with any other member functions of that instance.
|
||
|
||
[heading See Also]
|
||
[link json.ref.boost__json__parse `parse`], [link json.ref.boost__json__parser `parser`], [link json.ref.boost__json__parse_options `parse_options`],
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
[section:stream_parser stream_parser::stream_parser]
|
||
[indexterm2 stream_parser..stream_parser]
|
||
|
||
|
||
Copy constructor (deleted)
|
||
```
|
||
``[link json.ref.boost__json__stream_parser.stream_parser.overload1 stream_parser]``(
|
||
stream_parser const&);
|
||
``[''''»''' [link json.ref.boost__json__stream_parser.stream_parser.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Constructor.
|
||
```
|
||
``[link json.ref.boost__json__stream_parser.stream_parser.overload2 stream_parser]``(
|
||
storage_ptr sp,
|
||
parse_options const& opt,
|
||
unsigned char* buffer,
|
||
std::size_t size);
|
||
``[''''»''' [link json.ref.boost__json__stream_parser.stream_parser.overload2 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__stream_parser.stream_parser.overload3 stream_parser]``();
|
||
``[''''»''' [link json.ref.boost__json__stream_parser.stream_parser.overload3 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__stream_parser.stream_parser.overload4 stream_parser]``(
|
||
storage_ptr sp,
|
||
parse_options const& opt);
|
||
``[''''»''' [link json.ref.boost__json__stream_parser.stream_parser.overload4 `more...`]]``
|
||
|
||
explicit
|
||
``[link json.ref.boost__json__stream_parser.stream_parser.overload5 stream_parser]``(
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__stream_parser.stream_parser.overload5 `more...`]]``
|
||
|
||
template<
|
||
std::size_t N>
|
||
``[link json.ref.boost__json__stream_parser.stream_parser.overload6 stream_parser]``(
|
||
storage_ptr sp,
|
||
parse_options const& opt,
|
||
unsigned char(&) buffer \[N\]);
|
||
``[''''»''' [link json.ref.boost__json__stream_parser.stream_parser.overload6 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__stream_parser.stream_parser.overload7 stream_parser]``(
|
||
storage_ptr sp,
|
||
parse_options const& opt,
|
||
std::byte* buffer,
|
||
std::size_t size);
|
||
``[''''»''' [link json.ref.boost__json__stream_parser.stream_parser.overload7 `more...`]]``
|
||
|
||
template<
|
||
std::size_t N>
|
||
``[link json.ref.boost__json__stream_parser.stream_parser.overload8 stream_parser]``(
|
||
storage_ptr sp,
|
||
parse_options const& opt,
|
||
std::byte(&) buffer \[N\]);
|
||
``[''''»''' [link json.ref.boost__json__stream_parser.stream_parser.overload8 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 stream_parser::stream_parser (1 of 8 overloads)]
|
||
|
||
Copy constructor (deleted)
|
||
[heading Synopsis]
|
||
```
|
||
stream_parser(
|
||
stream_parser const&);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 stream_parser::stream_parser (2 of 8 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
stream_parser(
|
||
storage_ptr sp,
|
||
parse_options const& opt,
|
||
unsigned char* buffer,
|
||
std::size_t size);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This constructs a new parser which first uses the caller-owned storage pointed to by `buffer` for temporary storage, falling back to the memory resource `sp` if needed. The parser will use the specified parsing options.
|
||
|
||
|
||
The parsed value will use the default memory resource for storage. To use a different resource, call [link json.ref.boost__json__stream_parser.reset `reset`] after construction.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
The memory resource to use for temporary storage after `buffer` is exhausted.
|
||
]
|
||
]
|
||
[
|
||
[`opt`
|
||
]
|
||
[
|
||
The parsing options to use.
|
||
]
|
||
]
|
||
[
|
||
[`buffer`
|
||
]
|
||
[
|
||
A pointer to valid memory of at least `size` bytes for the parser to use for temporary storage. Ownership is not transferred, the caller is responsible for ensuring the lifetime of the memory pointed to by `buffer` extends until the parser is destroyed.
|
||
]
|
||
]
|
||
[
|
||
[`size`
|
||
]
|
||
[
|
||
The number of valid bytes in `buffer`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 stream_parser::stream_parser (3 of 8 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
stream_parser();
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This constructs a new parser which uses the default memory resource for temporary storage, and accepts only strict JSON.
|
||
|
||
|
||
The parsed value will use the default memory resource for storage. To use a different resource, call [link json.ref.boost__json__stream_parser.reset `reset`] after construction.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 stream_parser::stream_parser (4 of 8 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
stream_parser(
|
||
storage_ptr sp,
|
||
parse_options const& opt);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This constructs a new parser which uses the specified memory resource for temporary storage, and is configured to use the specified parsing options.
|
||
|
||
|
||
The parsed value will use the default memory resource for storage. To use a different resource, call [link json.ref.boost__json__stream_parser.reset `reset`] after construction.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
The memory resource to use for temporary storage.
|
||
]
|
||
]
|
||
[
|
||
[`opt`
|
||
]
|
||
[
|
||
The parsing options to use.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload5 stream_parser::stream_parser (5 of 8 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
stream_parser(
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This constructs a new parser which uses the specified memory resource for temporary storage, and accepts only strict JSON.
|
||
|
||
|
||
The parsed value will use the default memory resource for storage. To use a different resource, call [link json.ref.boost__json__stream_parser.reset `reset`] after construction.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
The memory resource to use for temporary storage.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload6 stream_parser::stream_parser (6 of 8 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
std::size_t N>
|
||
stream_parser(
|
||
storage_ptr sp,
|
||
parse_options const& opt,
|
||
unsigned char(&) buffer \[N\]);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This constructs a new parser which first uses the caller-owned storage `buffer` for temporary storage, falling back to the memory resource `sp` if needed. The parser will use the specified parsing options.
|
||
|
||
|
||
The parsed value will use the default memory resource for storage. To use a different resource, call [link json.ref.boost__json__stream_parser.reset `reset`] after construction.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
The memory resource to use for temporary storage after `buffer` is exhausted.
|
||
]
|
||
]
|
||
[
|
||
[`opt`
|
||
]
|
||
[
|
||
The parsing options to use.
|
||
]
|
||
]
|
||
[
|
||
[`buffer`
|
||
]
|
||
[
|
||
A buffer for the parser to use for temporary storage. Ownership is not transferred, the caller is responsible for ensuring the lifetime of `buffer` extends until the parser is destroyed.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload7 stream_parser::stream_parser (7 of 8 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
stream_parser(
|
||
storage_ptr sp,
|
||
parse_options const& opt,
|
||
std::byte* buffer,
|
||
std::size_t size);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This constructs a new parser which first uses the caller-owned storage pointed to by `buffer` for temporary storage, falling back to the memory resource `sp` if needed. The parser will use the specified parsing options.
|
||
|
||
|
||
The parsed value will use the default memory resource for storage. To use a different resource, call [link json.ref.boost__json__stream_parser.reset `reset`] after construction.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
The memory resource to use for temporary storage after `buffer` is exhausted.
|
||
]
|
||
]
|
||
[
|
||
[`opt`
|
||
]
|
||
[
|
||
The parsing options to use.
|
||
]
|
||
]
|
||
[
|
||
[`buffer`
|
||
]
|
||
[
|
||
A pointer to valid memory of at least `size` bytes for the parser to use for temporary storage. Ownership is not transferred, the caller is responsible for ensuring the lifetime of the memory pointed to by `buffer` extends until the parser is destroyed.
|
||
]
|
||
]
|
||
[
|
||
[`size`
|
||
]
|
||
[
|
||
The number of valid bytes in `buffer`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload8 stream_parser::stream_parser (8 of 8 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
std::size_t N>
|
||
stream_parser(
|
||
storage_ptr sp,
|
||
parse_options const& opt,
|
||
std::byte(&) buffer \[N\]);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
This constructs a new parser which first uses the caller-owned storage `buffer` for temporary storage, falling back to the memory resource `sp` if needed. The parser will use the specified parsing options.
|
||
|
||
|
||
The parsed value will use the default memory resource for storage. To use a different resource, call [link json.ref.boost__json__stream_parser.reset `reset`] after construction.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
The memory resource to use for temporary storage after `buffer` is exhausted.
|
||
]
|
||
]
|
||
[
|
||
[`opt`
|
||
]
|
||
[
|
||
The parsing options to use.
|
||
]
|
||
]
|
||
[
|
||
[`buffer`
|
||
]
|
||
[
|
||
A buffer for the parser to use for temporary storage. Ownership is not transferred, the caller is responsible for ensuring the lifetime of `buffer` extends until the parser is destroyed.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:operator_eq_ stream_parser::operator=]
|
||
[indexterm2 operator=..stream_parser]
|
||
|
||
|
||
Copy assignment (deleted)
|
||
[heading Synopsis]
|
||
```
|
||
stream_parser&
|
||
operator=(
|
||
stream_parser const&);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:_stream_parser stream_parser::~stream_parser]
|
||
[indexterm2 ~stream_parser..stream_parser]
|
||
|
||
|
||
Destructor.
|
||
[heading Synopsis]
|
||
```
|
||
~stream_parser();
|
||
```
|
||
|
||
[heading Description]
|
||
All dynamically allocated memory, including any incomplete parsing results, is freed.
|
||
|
||
[heading Complexity]
|
||
Linear in the size of partial results
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:reset stream_parser::reset]
|
||
[indexterm2 reset..stream_parser]
|
||
|
||
|
||
Reset the parser for a new JSON.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
reset(
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
This function is used to reset the parser to prepare it for parsing a new complete JSON. Any previous partial results are destroyed.
|
||
|
||
[heading Complexity]
|
||
Constant or linear in the size of any previous partial parsing results.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use for the resulting [link json.ref.boost__json__value `value`]. The parser will acquire shared ownership.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:done stream_parser::done]
|
||
[indexterm2 done..stream_parser]
|
||
|
||
|
||
Return true if a complete JSON has been parsed.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
done() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns `true` when all of these conditions are met:
|
||
|
||
* A complete serialized JSON has been presented to the parser, and
|
||
|
||
* No error has occurred since the parser was constructed, or since the last call to [link json.ref.boost__json__stream_parser.reset `reset`],
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:write_some stream_parser::write_some]
|
||
[indexterm2 write_some..stream_parser]
|
||
|
||
|
||
Parse a buffer containing all or part of a complete JSON.
|
||
```
|
||
std::size_t
|
||
``[link json.ref.boost__json__stream_parser.write_some.overload1 write_some]``(
|
||
char const* data,
|
||
std::size_t size,
|
||
error_code& ec);
|
||
``[''''»''' [link json.ref.boost__json__stream_parser.write_some.overload1 `more...`]]``
|
||
|
||
std::size_t
|
||
``[link json.ref.boost__json__stream_parser.write_some.overload2 write_some]``(
|
||
char const* data,
|
||
std::size_t size);
|
||
``[''''»''' [link json.ref.boost__json__stream_parser.write_some.overload2 `more...`]]``
|
||
|
||
std::size_t
|
||
``[link json.ref.boost__json__stream_parser.write_some.overload3 write_some]``(
|
||
string_view s,
|
||
error_code& ec);
|
||
``[''''»''' [link json.ref.boost__json__stream_parser.write_some.overload3 `more...`]]``
|
||
|
||
std::size_t
|
||
``[link json.ref.boost__json__stream_parser.write_some.overload4 write_some]``(
|
||
string_view s);
|
||
``[''''»''' [link json.ref.boost__json__stream_parser.write_some.overload4 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 stream_parser::write_some (1 of 4 overloads)]
|
||
|
||
Parse a buffer containing all or part of a complete JSON.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
write_some(
|
||
char const* data,
|
||
std::size_t size,
|
||
error_code& ec);
|
||
```
|
||
|
||
[heading Description]
|
||
This function parses JSON contained in the specified character buffer. If parsing completes, any additional characters past the end of the complete JSON are ignored. The function returns the actual number of characters parsed, which may be less than the size of the input. This allows parsing of a buffer containing multiple individual JSONs or containing different protocol data.
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
stream_parser p; // construct a parser
|
||
std::size_t n; // number of characters used
|
||
n = p.write_some( "\[1,2" ); // parse the first part of the JSON
|
||
assert( n == 4 ); // all characters consumed
|
||
n = p.write_some( "3,4\] null" ); // parse the rest of the JSON
|
||
assert( n == 5 ); // only some characters consumed
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
[heading Remarks]
|
||
|
||
To indicate there are no more character buffers, such as when [link json.ref.boost__json__stream_parser.done `done`] returns `false` after writing, call [link json.ref.boost__json__stream_parser.finish `finish`].
|
||
|
||
[heading Complexity]
|
||
Linear in `size`.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw. Upon error or exception, subsequent calls will fail until [link json.ref.boost__json__stream_parser.reset `reset`] is called to parse a new JSON.
|
||
[heading Return Value]
|
||
The number of characters consumed from the buffer.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`data`
|
||
]
|
||
[
|
||
A pointer to a buffer of `size` characters to parse.
|
||
]
|
||
]
|
||
[
|
||
[`size`
|
||
]
|
||
[
|
||
The number of characters pointed to by `data`.
|
||
]
|
||
]
|
||
[
|
||
[`ec`
|
||
]
|
||
[
|
||
Set to the error, if any occurred.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 stream_parser::write_some (2 of 4 overloads)]
|
||
|
||
Parse a buffer containing all or part of a complete JSON.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
write_some(
|
||
char const* data,
|
||
std::size_t size);
|
||
```
|
||
|
||
[heading Description]
|
||
This function parses JSON contained in the specified character buffer. If parsing completes, any additional characters past the end of the complete JSON are ignored. The function returns the actual number of characters parsed, which may be less than the size of the input. This allows parsing of a buffer containing multiple individual JSONs or containing different protocol data.
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
stream_parser p; // construct a parser
|
||
std::size_t n; // number of characters used
|
||
n = p.write_some( "\[1,2" ); // parse the first part of the JSON
|
||
assert( n == 4 ); // all characters consumed
|
||
n = p.write_some( "3,4\] null" ); // parse the rest of the JSON
|
||
assert( n == 5 ); // only some characters consumed
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
[heading Remarks]
|
||
|
||
To indicate there are no more character buffers, such as when [link json.ref.boost__json__stream_parser.done `done`] returns `false` after writing, call [link json.ref.boost__json__stream_parser.finish `finish`].
|
||
|
||
[heading Complexity]
|
||
Linear in `size`.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw. Upon error or exception, subsequent calls will fail until [link json.ref.boost__json__stream_parser.reset `reset`] is called to parse a new JSON.
|
||
[heading Return Value]
|
||
The number of characters consumed from the buffer.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`data`
|
||
]
|
||
[
|
||
A pointer to a buffer of `size` characters to parse.
|
||
]
|
||
]
|
||
[
|
||
[`size`
|
||
]
|
||
[
|
||
The number of characters pointed to by `data`.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`system_error`
|
||
]
|
||
[
|
||
Thrown on error.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 stream_parser::write_some (3 of 4 overloads)]
|
||
|
||
Parse a buffer containing all or part of a complete JSON.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
write_some(
|
||
string_view s,
|
||
error_code& ec);
|
||
```
|
||
|
||
[heading Description]
|
||
This function parses JSON contained in the specified character buffer. If parsing completes, any additional characters past the end of the complete JSON are ignored. The function returns the actual number of characters parsed, which may be less than the size of the input. This allows parsing of a buffer containing multiple individual JSONs or containing different protocol data.
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
stream_parser p; // construct a parser
|
||
std::size_t n; // number of characters used
|
||
n = p.write_some( "\[1,2" ); // parse the first part of the JSON
|
||
assert( n == 4 ); // all characters consumed
|
||
n = p.write_some( "3,4\] null" ); // parse the rest of the JSON
|
||
assert( n == 5 ); // only some characters consumed
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
[heading Remarks]
|
||
|
||
To indicate there are no more character buffers, such as when [link json.ref.boost__json__stream_parser.done `done`] returns `false` after writing, call [link json.ref.boost__json__stream_parser.finish `finish`].
|
||
|
||
[heading Complexity]
|
||
Linear in `size`.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw. Upon error or exception, subsequent calls will fail until [link json.ref.boost__json__stream_parser.reset `reset`] is called to parse a new JSON.
|
||
[heading Return Value]
|
||
The number of characters consumed from the buffer.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The character string to parse.
|
||
]
|
||
]
|
||
[
|
||
[`ec`
|
||
]
|
||
[
|
||
Set to the error, if any occurred.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 stream_parser::write_some (4 of 4 overloads)]
|
||
|
||
Parse a buffer containing all or part of a complete JSON.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
write_some(
|
||
string_view s);
|
||
```
|
||
|
||
[heading Description]
|
||
This function parses JSON contained in the specified character buffer. If parsing completes, any additional characters past the end of the complete JSON are ignored. The function returns the actual number of characters parsed, which may be less than the size of the input. This allows parsing of a buffer containing multiple individual JSONs or containing different protocol data.
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
stream_parser p; // construct a parser
|
||
std::size_t n; // number of characters used
|
||
n = p.write_some( "\[1,2" ); // parse the first part of the JSON
|
||
assert( n == 4 ); // all characters consumed
|
||
n = p.write_some( "3,4\] null" ); // parse the rest of the JSON
|
||
assert( n == 5 ); // only some characters consumed
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
[heading Remarks]
|
||
|
||
To indicate there are no more character buffers, such as when [link json.ref.boost__json__stream_parser.done `done`] returns `false` after writing, call [link json.ref.boost__json__stream_parser.finish `finish`].
|
||
|
||
[heading Complexity]
|
||
Linear in `size`.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw. Upon error or exception, subsequent calls will fail until [link json.ref.boost__json__stream_parser.reset `reset`] is called to parse a new JSON.
|
||
[heading Return Value]
|
||
The number of characters consumed from the buffer.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The character string to parse.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`system_error`
|
||
]
|
||
[
|
||
Thrown on error.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:write stream_parser::write]
|
||
[indexterm2 write..stream_parser]
|
||
|
||
|
||
Parse a buffer containing all or part of a complete JSON.
|
||
```
|
||
std::size_t
|
||
``[link json.ref.boost__json__stream_parser.write.overload1 write]``(
|
||
char const* data,
|
||
std::size_t size,
|
||
error_code& ec);
|
||
``[''''»''' [link json.ref.boost__json__stream_parser.write.overload1 `more...`]]``
|
||
|
||
std::size_t
|
||
``[link json.ref.boost__json__stream_parser.write.overload2 write]``(
|
||
char const* data,
|
||
std::size_t size);
|
||
``[''''»''' [link json.ref.boost__json__stream_parser.write.overload2 `more...`]]``
|
||
|
||
std::size_t
|
||
``[link json.ref.boost__json__stream_parser.write.overload3 write]``(
|
||
string_view s,
|
||
error_code& ec);
|
||
``[''''»''' [link json.ref.boost__json__stream_parser.write.overload3 `more...`]]``
|
||
|
||
std::size_t
|
||
``[link json.ref.boost__json__stream_parser.write.overload4 write]``(
|
||
string_view s);
|
||
``[''''»''' [link json.ref.boost__json__stream_parser.write.overload4 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 stream_parser::write (1 of 4 overloads)]
|
||
|
||
Parse a buffer containing all or part of a complete JSON.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
write(
|
||
char const* data,
|
||
std::size_t size,
|
||
error_code& ec);
|
||
```
|
||
|
||
[heading Description]
|
||
This function parses a all or part of a JSON contained in the specified character buffer. The entire buffer must be consumed; if there are additional characters past the end of the complete JSON, the parse fails and an error is returned.
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
stream_parser p; // construct a parser
|
||
std::size_t n; // number of characters used
|
||
n = p.write( "\[1,2" ); // parse some of the JSON
|
||
assert( n == 4 ); // all characters consumed
|
||
n = p.write( "3,4\]" ); // parse the rest of the JSON
|
||
assert( n == 4 ); // all characters consumed
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
[heading Remarks]
|
||
|
||
To indicate there are no more character buffers, such as when [link json.ref.boost__json__stream_parser.done `done`] returns `false` after writing, call [link json.ref.boost__json__stream_parser.finish `finish`].
|
||
|
||
[heading Complexity]
|
||
Linear in `size`.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw. Upon error or exception, subsequent calls will fail until [link json.ref.boost__json__stream_parser.reset `reset`] is called to parse a new JSON.
|
||
[heading Return Value]
|
||
The number of characters consumed from the buffer.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`data`
|
||
]
|
||
[
|
||
A pointer to a buffer of `size` characters to parse.
|
||
]
|
||
]
|
||
[
|
||
[`size`
|
||
]
|
||
[
|
||
The number of characters pointed to by `data`.
|
||
]
|
||
]
|
||
[
|
||
[`ec`
|
||
]
|
||
[
|
||
Set to the error, if any occurred.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 stream_parser::write (2 of 4 overloads)]
|
||
|
||
Parse a buffer containing all or part of a complete JSON.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
write(
|
||
char const* data,
|
||
std::size_t size);
|
||
```
|
||
|
||
[heading Description]
|
||
This function parses a all or part of a JSON contained in the specified character buffer. The entire buffer must be consumed; if there are additional characters past the end of the complete JSON, the parse fails and an error is returned.
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
stream_parser p; // construct a parser
|
||
std::size_t n; // number of characters used
|
||
n = p.write( "\[1,2" ); // parse some of the JSON
|
||
assert( n == 4 ); // all characters consumed
|
||
n = p.write( "3,4\]" ); // parse the rest of the JSON
|
||
assert( n == 4 ); // all characters consumed
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
[heading Remarks]
|
||
|
||
To indicate there are no more character buffers, such as when [link json.ref.boost__json__stream_parser.done `done`] returns `false` after writing, call [link json.ref.boost__json__stream_parser.finish `finish`].
|
||
|
||
[heading Complexity]
|
||
Linear in `size`.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw. Upon error or exception, subsequent calls will fail until [link json.ref.boost__json__stream_parser.reset `reset`] is called to parse a new JSON.
|
||
[heading Return Value]
|
||
The number of characters consumed from the buffer.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`data`
|
||
]
|
||
[
|
||
A pointer to a buffer of `size` characters to parse.
|
||
]
|
||
]
|
||
[
|
||
[`size`
|
||
]
|
||
[
|
||
The number of characters pointed to by `data`.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`system_error`
|
||
]
|
||
[
|
||
Thrown on error.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 stream_parser::write (3 of 4 overloads)]
|
||
|
||
Parse a buffer containing all or part of a complete JSON.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
write(
|
||
string_view s,
|
||
error_code& ec);
|
||
```
|
||
|
||
[heading Description]
|
||
This function parses a all or part of a JSON contained in the specified character buffer. The entire buffer must be consumed; if there are additional characters past the end of the complete JSON, the parse fails and an error is returned.
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
stream_parser p; // construct a parser
|
||
std::size_t n; // number of characters used
|
||
n = p.write( "\[1,2" ); // parse some of the JSON
|
||
assert( n == 4 ); // all characters consumed
|
||
n = p.write( "3,4\]" ); // parse the rest of the JSON
|
||
assert( n == 4 ); // all characters consumed
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
[heading Remarks]
|
||
|
||
To indicate there are no more character buffers, such as when [link json.ref.boost__json__stream_parser.done `done`] returns `false` after writing, call [link json.ref.boost__json__stream_parser.finish `finish`].
|
||
|
||
[heading Complexity]
|
||
Linear in `size`.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw. Upon error or exception, subsequent calls will fail until [link json.ref.boost__json__stream_parser.reset `reset`] is called to parse a new JSON.
|
||
[heading Return Value]
|
||
The number of characters consumed from the buffer.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The character string to parse.
|
||
]
|
||
]
|
||
[
|
||
[`ec`
|
||
]
|
||
[
|
||
Set to the error, if any occurred.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 stream_parser::write (4 of 4 overloads)]
|
||
|
||
Parse a buffer containing all or part of a complete JSON.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
write(
|
||
string_view s);
|
||
```
|
||
|
||
[heading Description]
|
||
This function parses a all or part of a JSON contained in the specified character buffer. The entire buffer must be consumed; if there are additional characters past the end of the complete JSON, the parse fails and an error is returned.
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
stream_parser p; // construct a parser
|
||
std::size_t n; // number of characters used
|
||
n = p.write( "\[1,2" ); // parse some of the JSON
|
||
assert( n == 4 ); // all characters consumed
|
||
n = p.write( "3,4\]" ); // parse the rest of the JSON
|
||
assert( n == 4 ); // all characters consumed
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
[heading Remarks]
|
||
|
||
To indicate there are no more character buffers, such as when [link json.ref.boost__json__stream_parser.done `done`] returns `false` after writing, call [link json.ref.boost__json__stream_parser.finish `finish`].
|
||
|
||
[heading Complexity]
|
||
Linear in `size`.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw. Upon error or exception, subsequent calls will fail until [link json.ref.boost__json__stream_parser.reset `reset`] is called to parse a new JSON.
|
||
[heading Return Value]
|
||
The number of characters consumed from the buffer.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The character string to parse.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`system_error`
|
||
]
|
||
[
|
||
Thrown on error.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:finish stream_parser::finish]
|
||
[indexterm2 finish..stream_parser]
|
||
|
||
|
||
Indicate the end of JSON input.
|
||
```
|
||
void
|
||
``[link json.ref.boost__json__stream_parser.finish.overload1 finish]``(
|
||
error_code& ec);
|
||
``[''''»''' [link json.ref.boost__json__stream_parser.finish.overload1 `more...`]]``
|
||
|
||
void
|
||
``[link json.ref.boost__json__stream_parser.finish.overload2 finish]``();
|
||
``[''''»''' [link json.ref.boost__json__stream_parser.finish.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 stream_parser::finish (1 of 2 overloads)]
|
||
|
||
Indicate the end of JSON input.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
finish(
|
||
error_code& ec);
|
||
```
|
||
|
||
[heading Description]
|
||
This function is used to indicate that there are no more character buffers in the current JSON being parsed. If ther resulting JSON is incomplete, the error is set to indicate a parsing failure.
|
||
|
||
[heading Example]
|
||
|
||
In the code below, [link json.ref.boost__json__stream_parser.finish `finish`] is called to indicate there are no more digits in the resulting number:
|
||
```
|
||
stream_parser p; // construct a parser
|
||
p.write( "3." ); // write the first part of the number
|
||
p.write( "14" ); // write the second part of the number
|
||
assert( ! p.done() ); // there could be more digits
|
||
p.finish(); // indicate the end of the JSON input
|
||
assert( p.done() ); // now we are finished
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw. Upon error or exception, subsequent calls will fail until [link json.ref.boost__json__stream_parser.reset `reset`] is called to parse a new JSON.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`ec`
|
||
]
|
||
[
|
||
Set to the error, if any occurred.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 stream_parser::finish (2 of 2 overloads)]
|
||
|
||
Indicate the end of JSON input.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
finish();
|
||
```
|
||
|
||
[heading Description]
|
||
This function is used to indicate that there are no more character buffers in the current JSON being parsed. If ther resulting JSON is incomplete, the error is set to indicate a parsing failure.
|
||
|
||
[heading Example]
|
||
|
||
In the code below, [link json.ref.boost__json__stream_parser.finish `finish`] is called to indicate there are no more digits in the resulting number:
|
||
```
|
||
stream_parser p; // construct a parser
|
||
p.write( "3." ); // write the first part of the number
|
||
p.write( "14" ); // write the second part of the number
|
||
assert( ! p.done() ); // there could be more digits
|
||
p.finish(); // indicate the end of the JSON input
|
||
assert( p.done() ); // now we are finished
|
||
value jv = p.release(); // take ownership of the value
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw. Upon error or exception, subsequent calls will fail until [link json.ref.boost__json__stream_parser.reset `reset`] is called to parse a new JSON.
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`system_error`
|
||
]
|
||
[
|
||
Thrown on error.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:release stream_parser::release]
|
||
[indexterm2 release..stream_parser]
|
||
|
||
|
||
Return the parsed JSON as a [link json.ref.boost__json__value `value`].
|
||
[heading Synopsis]
|
||
```
|
||
value
|
||
release();
|
||
```
|
||
|
||
[heading Description]
|
||
This returns the parsed value, or throws an exception if the parsing is incomplete or failed. It is necessary to call [link json.ref.boost__json__stream_parser.reset `reset`] after calling this function in order to parse another JSON.
|
||
|
||
[heading Effects]
|
||
|
||
```
|
||
if( ! this->done() )
|
||
this->finish();
|
||
```
|
||
|
||
[heading Remarks]
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Return Value]
|
||
The parsed value. Ownership of this value is transferred to the caller.
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`system_error`
|
||
]
|
||
[
|
||
Thrown on failure.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__string string]
|
||
|
||
The native type of string values.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/string.hpp]
|
||
|
||
```
|
||
class string
|
||
```
|
||
|
||
[heading Types]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__string.allocator_type allocator_type]]
|
||
]
|
||
[The type of ['Allocator] returned by [link json.ref.boost__json__string.get_allocator `get_allocator`].
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.const_iterator const_iterator]]
|
||
]
|
||
[A random access const iterator to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.const_pointer const_pointer]]
|
||
]
|
||
[A const pointer to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.const_reference const_reference]]
|
||
]
|
||
[A const reference to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.const_reverse_iterator const_reverse_iterator]]
|
||
]
|
||
[A reverse random access const iterator to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.difference_type difference_type]]
|
||
]
|
||
[The type used to represent signed integers.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.iterator iterator]]
|
||
]
|
||
[A random access iterator to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.pointer pointer]]
|
||
]
|
||
[A pointer to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.reference reference]]
|
||
]
|
||
[A reference to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.reverse_iterator reverse_iterator]]
|
||
]
|
||
[A reverse random access iterator to an element.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.size_type size_type]]
|
||
]
|
||
[The type used to represent unsigned integers.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.value_type value_type]]
|
||
]
|
||
[The type of a character.
|
||
]
|
||
]
|
||
]
|
||
[heading Member Functions]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__string.append append]]
|
||
]
|
||
[Append characters to the string. [br][role silver —][br]Append a string to the string. [br][role silver —][br]Append a range of characters.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.assign assign]]
|
||
]
|
||
[Assign characters to a string.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.at at]]
|
||
]
|
||
[Return a character with bounds checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.back back]]
|
||
]
|
||
[Return the last character.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.begin begin]]
|
||
]
|
||
[Return an iterator to the beginning.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.c_str c_str]]
|
||
]
|
||
[Return the underlying character array directly.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.capacity capacity]]
|
||
]
|
||
[Return the number of characters that can be held without a reallocation.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.cbegin cbegin]]
|
||
]
|
||
[Return an iterator to the beginning.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.cend cend]]
|
||
]
|
||
[Return an iterator to the end.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.clear clear]]
|
||
]
|
||
[Clear the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.compare compare]]
|
||
]
|
||
[Compare a string with the string.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.copy copy]]
|
||
]
|
||
[Copy a substring to another string.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.crbegin crbegin]]
|
||
]
|
||
[Return a reverse iterator to the first character of the reversed container.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.crend crend]]
|
||
]
|
||
[Return a reverse iterator to the character following the last character of the reversed container.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.data data]]
|
||
]
|
||
[Return the underlying character array directly.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.empty empty]]
|
||
]
|
||
[Check if the string has no characters.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.end end]]
|
||
]
|
||
[Return an iterator to the end.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.ends_with ends_with]]
|
||
]
|
||
[Return whether the string end with a string. [br][role silver —][br]Return whether the string ends with a character.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.erase erase]]
|
||
]
|
||
[Erase characters from the string. [br][role silver —][br]Erase a character from the string. [br][role silver —][br]Erase a range from the string.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.find find]]
|
||
]
|
||
[Find the first occurrence of a string within the string. [br][role silver —][br]Find the first occurrence of a character within the string.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.find_first_not_of find_first_not_of]]
|
||
]
|
||
[Find the first occurrence of any of the characters not within the string. [br][role silver —][br]Find the first occurrence of a character not equal to `ch`.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.find_first_of find_first_of]]
|
||
]
|
||
[Find the first occurrence of any of the characters within the string.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.find_last_not_of find_last_not_of]]
|
||
]
|
||
[Find the last occurrence of a character not within the string. [br][role silver —][br]Find the last occurrence of a character not equal to `ch`.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.find_last_of find_last_of]]
|
||
]
|
||
[Find the last occurrence of any of the characters within the string.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.front front]]
|
||
]
|
||
[Return the first character.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.get_allocator get_allocator]]
|
||
]
|
||
[Return the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.grow grow]]
|
||
]
|
||
[Increase size without changing capacity.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.insert insert]]
|
||
]
|
||
[Insert a string. [br][role silver —][br]Insert a character. [br][role silver —][br]Insert a range of characters.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.operator_string_view operator string_view]]
|
||
]
|
||
[Convert to a `string_view` referring to the string.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.operator_plus__eq_ operator+=]]
|
||
]
|
||
[Append characters from a string. [br][role silver —][br]Append a character.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.operator_eq_ operator=]]
|
||
]
|
||
[Copy assignment. [br][role silver —][br]Move assignment. [br][role silver —][br]Assign a value to the string.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.operator_lb__rb_ operator\[\]]]
|
||
]
|
||
[Return a character without bounds checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.pop_back pop_back]]
|
||
]
|
||
[Remove the last character.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.push_back push_back]]
|
||
]
|
||
[Append a character.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.rbegin rbegin]]
|
||
]
|
||
[Return a reverse iterator to the first character of the reversed container.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.rend rend]]
|
||
]
|
||
[Return a reverse iterator to the character following the last character of the reversed container.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.replace replace]]
|
||
]
|
||
[Replace a substring with a string. [br][role silver —][br]Replace a range with a string. [br][role silver —][br]Replace a range with a range. [br][role silver —][br]Replace a substring with copies of a character. [br][role silver —][br]Replace a range with copies of a character.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.reserve reserve]]
|
||
]
|
||
[Increase the capacity to at least a certain amount.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.resize resize]]
|
||
]
|
||
[Change the size of the string.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.rfind rfind]]
|
||
]
|
||
[Find the last occurrence of a string within the string. [br][role silver —][br]Find the last occurrence of a character within the string.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.shrink_to_fit shrink_to_fit]]
|
||
]
|
||
[Request the removal of unused capacity.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.size size]]
|
||
]
|
||
[Return the number of characters in the string.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.starts_with starts_with]]
|
||
]
|
||
[Return whether the string begins with a string. [br][role silver —][br]Return whether the string begins with a character.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.storage storage]]
|
||
]
|
||
[Return the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.string string] [role silver \[constructor\]]]
|
||
]
|
||
[Default constructor. [br][role silver —][br]Pilfer constructor. [br][role silver —][br]Constructor. [br][role silver —][br]Copy constructor. [br][role silver —][br]Move constructor.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.subview subview]]
|
||
]
|
||
[Return a substring.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string.swap swap]]
|
||
]
|
||
[Swap the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__string._string ~string] [role silver \[destructor\]]]
|
||
]
|
||
[Destructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Static Members]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__string.max_size max_size]]
|
||
]
|
||
[Return the maximum number of characters any string can hold.
|
||
]
|
||
]
|
||
]
|
||
[heading Static Members]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__string.npos npos]]
|
||
]
|
||
[A special index.
|
||
]
|
||
]
|
||
]
|
||
[heading Friends]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__string.swap swap]]
|
||
]
|
||
[Exchange the given values.
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
Instances of string store and manipulate sequences of `char` using the UTF-8 encoding. The elements of a string are stored contiguously. A pointer to any character in a string may be passed to functions that expect a pointer to the first element of a null-terminated `char` array.
|
||
String iterators are regular `char` pointers.
|
||
|
||
[heading Remarks]
|
||
`string` member functions do not validate any UTF-8 byte sequences passed to them.
|
||
[heading Thread Safety]
|
||
|
||
Non-const member functions may not be called concurrently with any other member functions.
|
||
|
||
[heading Satisfies]
|
||
[@https://en.cppreference.com/w/cpp/named_req/ContiguousContainer ['ContiguousContainer]], [@https://en.cppreference.com/w/cpp/named_req/ReversibleContainer ['ReversibleContainer]], and [@https://en.cppreference.com/w/cpp/named_req/SequenceContainer ['SequenceContainer]].
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
[section:allocator_type string::allocator_type]
|
||
[indexterm2 allocator_type..string]
|
||
|
||
|
||
The type of ['Allocator] returned by [link json.ref.boost__json__string.get_allocator `get_allocator`].
|
||
[heading Synopsis]
|
||
```
|
||
using allocator_type = ``['see-below]``;
|
||
```
|
||
|
||
[heading Description]
|
||
This type is a [link json.ref.boost__json__polymorphic_allocator `polymorphic_allocator`].
|
||
|
||
[endsect]
|
||
|
||
[section:value_type string::value_type]
|
||
[indexterm2 value_type..string]
|
||
|
||
|
||
The type of a character.
|
||
[heading Synopsis]
|
||
```
|
||
using value_type = char;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:size_type string::size_type]
|
||
[indexterm2 size_type..string]
|
||
|
||
|
||
The type used to represent unsigned integers.
|
||
[heading Synopsis]
|
||
```
|
||
using size_type = std::size_t;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:difference_type string::difference_type]
|
||
[indexterm2 difference_type..string]
|
||
|
||
|
||
The type used to represent signed integers.
|
||
[heading Synopsis]
|
||
```
|
||
using difference_type = std::ptrdiff_t;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:pointer string::pointer]
|
||
[indexterm2 pointer..string]
|
||
|
||
|
||
A pointer to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using pointer = char*;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:const_pointer string::const_pointer]
|
||
[indexterm2 const_pointer..string]
|
||
|
||
|
||
A const pointer to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using const_pointer = char const*;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:reference string::reference]
|
||
[indexterm2 reference..string]
|
||
|
||
|
||
A reference to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using reference = char&;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:const_reference string::const_reference]
|
||
[indexterm2 const_reference..string]
|
||
|
||
|
||
A const reference to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using const_reference = const char&;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:iterator string::iterator]
|
||
[indexterm2 iterator..string]
|
||
|
||
|
||
A random access iterator to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using iterator = char*;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:const_iterator string::const_iterator]
|
||
[indexterm2 const_iterator..string]
|
||
|
||
|
||
A random access const iterator to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using const_iterator = char const*;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:reverse_iterator string::reverse_iterator]
|
||
[indexterm2 reverse_iterator..string]
|
||
|
||
|
||
A reverse random access iterator to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using reverse_iterator = std::reverse_iterator< iterator >;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:const_reverse_iterator string::const_reverse_iterator]
|
||
[indexterm2 const_reverse_iterator..string]
|
||
|
||
|
||
A reverse random access const iterator to an element.
|
||
[heading Synopsis]
|
||
```
|
||
using const_reverse_iterator = std::reverse_iterator< const_iterator >;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:swap string::swap]
|
||
[indexterm2 swap..string]
|
||
|
||
|
||
Exchange the given values.
|
||
```
|
||
friend void
|
||
``[link json.ref.boost__json__string.swap.overload1 swap]``(
|
||
string& lhs,
|
||
string& rhs);
|
||
``[''''»''' [link json.ref.boost__json__string.swap.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Swap the contents.
|
||
```
|
||
void
|
||
``[link json.ref.boost__json__string.swap.overload2 swap]``(
|
||
string& other);
|
||
``[''''»''' [link json.ref.boost__json__string.swap.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::swap (1 of 2 overloads)]
|
||
|
||
Exchange the given values.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/string.hpp]
|
||
|
||
```
|
||
friend void
|
||
swap(
|
||
string& lhs,
|
||
string& rhs);
|
||
```
|
||
|
||
[heading Description]
|
||
Exchanges the contents of the string `lhs` with another string `rhs`. Ownership of the respective [link json.ref.boost__json__memory_resource `memory_resource`] objects is not transferred.
|
||
|
||
* If `*lhs.storage() == *rhs.storage()`, ownership of the underlying memory is swapped in constant time, with no possibility of exceptions. All iterators and references remain valid.
|
||
|
||
* If `*lhs.storage() != *rhs.storage()`, the contents are logically swapped by making a copy, which can throw. In this case all iterators and references are invalidated.
|
||
|
||
[heading Effects]
|
||
|
||
```
|
||
lhs.swap( rhs );
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant or linear in `lhs.size() + rhs.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`lhs`
|
||
]
|
||
[
|
||
The string to exchange.
|
||
]
|
||
]
|
||
[
|
||
[`rhs`
|
||
]
|
||
[
|
||
The string to exchange. If `&lhs == &rhs`, this function call has no effect.
|
||
]
|
||
]
|
||
]
|
||
[heading See Also]
|
||
[link json.ref.boost__json__string.swap `string::swap`]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::swap (2 of 2 overloads)]
|
||
|
||
Swap the contents.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
swap(
|
||
string& other);
|
||
```
|
||
|
||
[heading Description]
|
||
Exchanges the contents of this string with another string. Ownership of the respective [link json.ref.boost__json__memory_resource `memory_resource`] objects is not transferred.
|
||
|
||
* If `*other.storage() == *this->storage()`, ownership of the underlying memory is swapped in constant time, with no possibility of exceptions. All iterators and references remain valid.
|
||
|
||
* If `*other.storage() != *this->storage()`, the contents are logically swapped by making copies, which can throw. In this case all iterators and references are invalidated.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant or linear in [link json.ref.boost__json__string.size `size()`] plus `other.size()`.
|
||
|
||
[heading Precondition]
|
||
|
||
```
|
||
&other != this
|
||
```
|
||
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The string to swap with If `this == &other`, this function call has no effect.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:npos string::npos]
|
||
[indexterm2 npos..string]
|
||
|
||
|
||
A special index.
|
||
[heading Synopsis]
|
||
```
|
||
static
|
||
constexpr std::size_t npos =
|
||
string_view::npos;
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:_string string::~string]
|
||
[indexterm2 ~string..string]
|
||
|
||
|
||
Destructor.
|
||
[heading Synopsis]
|
||
```
|
||
~string();
|
||
```
|
||
|
||
[heading Description]
|
||
Any dynamically allocated internal storage is freed.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:string string::string]
|
||
[indexterm2 string..string]
|
||
|
||
|
||
Default constructor.
|
||
```
|
||
``[link json.ref.boost__json__string.string.overload1 string]``();
|
||
``[''''»''' [link json.ref.boost__json__string.string.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Pilfer constructor.
|
||
```
|
||
``[link json.ref.boost__json__string.string.overload2 string]``(
|
||
pilfered< string > other);
|
||
``[''''»''' [link json.ref.boost__json__string.string.overload2 `more...`]]``
|
||
```
|
||
|
||
|
||
Constructor.
|
||
```
|
||
explicit
|
||
``[link json.ref.boost__json__string.string.overload3 string]``(
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__string.string.overload3 `more...`]]``
|
||
|
||
explicit
|
||
``[link json.ref.boost__json__string.string.overload4 string]``(
|
||
std::size_t count,
|
||
char ch,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__string.string.overload4 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__string.string.overload5 string]``(
|
||
char const* s,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__string.string.overload5 `more...`]]``
|
||
|
||
explicit
|
||
``[link json.ref.boost__json__string.string.overload6 string]``(
|
||
char const* s,
|
||
std::size_t count,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__string.string.overload6 `more...`]]``
|
||
|
||
template<
|
||
class InputIt>
|
||
explicit
|
||
``[link json.ref.boost__json__string.string.overload7 string]``(
|
||
InputIt first,
|
||
InputIt last,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__string.string.overload7 `more...`]]``
|
||
|
||
explicit
|
||
``[link json.ref.boost__json__string.string.overload9 string]``(
|
||
string const& other,
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__string.string.overload9 `more...`]]``
|
||
|
||
explicit
|
||
``[link json.ref.boost__json__string.string.overload11 string]``(
|
||
string&& other,
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__string.string.overload11 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__string.string.overload12 string]``(
|
||
string_view s,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__string.string.overload12 `more...`]]``
|
||
```
|
||
|
||
|
||
Copy constructor.
|
||
```
|
||
``[link json.ref.boost__json__string.string.overload8 string]``(
|
||
string const& other);
|
||
``[''''»''' [link json.ref.boost__json__string.string.overload8 `more...`]]``
|
||
```
|
||
|
||
|
||
Move constructor.
|
||
```
|
||
``[link json.ref.boost__json__string.string.overload10 string]``(
|
||
string&& other);
|
||
``[''''»''' [link json.ref.boost__json__string.string.overload10 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::string (1 of 12 overloads)]
|
||
|
||
Default constructor.
|
||
[heading Synopsis]
|
||
```
|
||
string();
|
||
```
|
||
|
||
[heading Description]
|
||
The string will have a zero size and a non-zero, unspecified capacity, using the default memory resource.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::string (2 of 12 overloads)]
|
||
|
||
Pilfer constructor.
|
||
[heading Synopsis]
|
||
```
|
||
string(
|
||
pilfered< string > other);
|
||
```
|
||
|
||
[heading Description]
|
||
The string is constructed by acquiring ownership of the contents of `other` using pilfer semantics. This is more efficient than move construction, when it is known that the moved-from object will be immediately destroyed afterwards.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The value to pilfer. After pilfer construction, `other` is not in a usable state and may only be destroyed.
|
||
]
|
||
]
|
||
]
|
||
[heading See Also]
|
||
[link json.ref.boost__json__pilfer `pilfer`], [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0308r0.html Valueless Variants Considered Harmful]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 string::string (3 of 12 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
string(
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
The string will have zero size and a non-zero, unspecified capacity, obtained from the specified memory resource.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 string::string (4 of 12 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
string(
|
||
std::size_t count,
|
||
char ch,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
Construct the contents with `count` copies of character `ch`.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear in `count`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`count`
|
||
]
|
||
[
|
||
The size of the resulting string.
|
||
]
|
||
]
|
||
[
|
||
[`ch`
|
||
]
|
||
[
|
||
The value to initialize characters of the string with.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
An optional pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource. The default argument for this parameter is `{}`.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`count > max_size()`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload5 string::string (5 of 12 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
string(
|
||
char const* s,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
Construct the contents with those of the null terminated string pointed to by `s`. The length of the string is determined by the first null character.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear in `strlen(s)`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
A pointer to a character string used to copy from.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
An optional pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource. The default argument for this parameter is `{}`.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`strlen(s) > max_size()`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload6 string::string (6 of 12 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
string(
|
||
char const* s,
|
||
std::size_t count,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
Construct the contents with copies of the characters in the range `{s, s+count)`. This range can contain null characters.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear in `count`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`count`
|
||
]
|
||
[
|
||
The number of characters to copy.
|
||
]
|
||
]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
A pointer to a character string used to copy from.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
An optional pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource. The default argument for this parameter is `{}`.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`count > max_size()`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload7 string::string (7 of 12 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class InputIt>
|
||
string(
|
||
InputIt first,
|
||
InputIt last,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
Construct the contents with copies of characters in the range `{first, last)`.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear in `std::distance(first, last)`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Template Parameters]
|
||
[table [[Type][Description]]
|
||
[
|
||
[`InputIt`
|
||
]
|
||
[
|
||
The type of the iterators.
|
||
]
|
||
]
|
||
]
|
||
[heading Constraints]
|
||
|
||
`InputIt`satisfies [*InputIterator].
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`first`
|
||
]
|
||
[
|
||
An input iterator pointing to the first character to insert, or pointing to the end of the range.
|
||
]
|
||
]
|
||
[
|
||
[`last`
|
||
]
|
||
[
|
||
An input iterator pointing to the end of the range.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
An optional pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource. The default argument for this parameter is `{}`.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`std::distance(first, last) > max_size()`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload8 string::string (8 of 12 overloads)]
|
||
|
||
Copy constructor.
|
||
[heading Synopsis]
|
||
```
|
||
string(
|
||
string const& other);
|
||
```
|
||
|
||
[heading Description]
|
||
Construct the contents with a copy of `other`.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear in `other.size()`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The string to use as a source to copy from.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload9 string::string (9 of 12 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
string(
|
||
string const& other,
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
Construct the contents with a copy of `other`.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear in `other.size()`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The string to use as a source to copy from.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
An optional pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource. The default argument for this parameter is `{}`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload10 string::string (10 of 12 overloads)]
|
||
|
||
Move constructor.
|
||
[heading Synopsis]
|
||
```
|
||
string(
|
||
string&& other);
|
||
```
|
||
|
||
[heading Description]
|
||
Constructs the string with the contents of `other` using move semantics. Ownership of the underlying memory is transferred. The container acquires shared ownership of the [link json.ref.boost__json__memory_resource `memory_resource`] used by `other`. After construction, the moved-from string behaves as if newly constructed with its current memory resource.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The string to move
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload11 string::string (11 of 12 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
string(
|
||
string&& other,
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
Construct the contents with those of `other` using move semantics.
|
||
|
||
* If `*other.storage() == *sp`, ownership of the underlying memory is transferred in constant time, with no possibility of exceptions. After construction, the moved-from string behaves as if newly constructed with its current [link json.ref.boost__json__memory_resource `memory_resource`]. Otherwise,
|
||
|
||
* If `*other.storage() != *sp`, a copy of the characters in `other` is made. In this case, the moved-from string is not changed.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant or linear in `other.size()`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The string to assign from.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
An optional pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource. The default argument for this parameter is `{}`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload12 string::string (12 of 12 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
string(
|
||
string_view s,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
Construct the contents with those of a string view. This view can contain null characters.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear in `s.size()`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The string view to copy from.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
An optional pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource. The default argument for this parameter is `{}`.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`s.size() > max_size()`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:operator_eq_ string::operator=]
|
||
[indexterm2 operator=..string]
|
||
|
||
|
||
Copy assignment.
|
||
```
|
||
string&
|
||
``[link json.ref.boost__json__string.operator_eq_.overload1 operator=]``(
|
||
string const& other);
|
||
``[''''»''' [link json.ref.boost__json__string.operator_eq_.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Move assignment.
|
||
```
|
||
string&
|
||
``[link json.ref.boost__json__string.operator_eq_.overload2 operator=]``(
|
||
string&& other);
|
||
``[''''»''' [link json.ref.boost__json__string.operator_eq_.overload2 `more...`]]``
|
||
```
|
||
|
||
|
||
Assign a value to the string.
|
||
```
|
||
string&
|
||
``[link json.ref.boost__json__string.operator_eq_.overload3 operator=]``(
|
||
char const* s);
|
||
``[''''»''' [link json.ref.boost__json__string.operator_eq_.overload3 `more...`]]``
|
||
|
||
string&
|
||
``[link json.ref.boost__json__string.operator_eq_.overload4 operator=]``(
|
||
string_view s);
|
||
``[''''»''' [link json.ref.boost__json__string.operator_eq_.overload4 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::operator= (1 of 4 overloads)]
|
||
|
||
Copy assignment.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
operator=(
|
||
string const& other);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace the contents with a copy of `other`.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear in `other.size()`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The string to use as a source to copy from.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::operator= (2 of 4 overloads)]
|
||
|
||
Move assignment.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
operator=(
|
||
string&& other);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace the contents with those of `other` using move semantics.
|
||
|
||
* If `*other.storage() == *this->storage()`, ownership of the underlying memory is transferred in constant time, with no possibility of exceptions. After construction, the moved-from string behaves as if newly constructed with its current [link json.ref.boost__json__memory_resource `memory_resource`]. Otherwise,
|
||
|
||
* If `*other.storage() != *this->storage()`, a copy of the characters in `other` is made. In this case, the moved-from container is not changed.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant or linear in `other.size()`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The string to use as a source to move from.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 string::operator= (3 of 4 overloads)]
|
||
|
||
Assign a value to the string.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
operator=(
|
||
char const* s);
|
||
```
|
||
|
||
[heading Description]
|
||
Replaces the contents with those of the null terminated string pointed to by `s`. The length of the string is determined by the first null character.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear in `std::strlen(s)`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The null-terminated character string.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`std::strlen(s) > max_size()`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 string::operator= (4 of 4 overloads)]
|
||
|
||
Assign a value to the string.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
operator=(
|
||
string_view s);
|
||
```
|
||
|
||
[heading Description]
|
||
Replaces the contents with those of a string view. This view can contain null characters.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear in `s.size()`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The string view to copy from.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`s.size() > max_size()`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:assign string::assign]
|
||
[indexterm2 assign..string]
|
||
|
||
|
||
Assign characters to a string.
|
||
```
|
||
string&
|
||
``[link json.ref.boost__json__string.assign.overload1 assign]``(
|
||
std::size_t count,
|
||
char ch);
|
||
``[''''»''' [link json.ref.boost__json__string.assign.overload1 `more...`]]``
|
||
|
||
string&
|
||
``[link json.ref.boost__json__string.assign.overload2 assign]``(
|
||
string const& other);
|
||
``[''''»''' [link json.ref.boost__json__string.assign.overload2 `more...`]]``
|
||
|
||
string&
|
||
``[link json.ref.boost__json__string.assign.overload3 assign]``(
|
||
string&& other);
|
||
``[''''»''' [link json.ref.boost__json__string.assign.overload3 `more...`]]``
|
||
|
||
string&
|
||
``[link json.ref.boost__json__string.assign.overload4 assign]``(
|
||
char const* s,
|
||
std::size_t count);
|
||
``[''''»''' [link json.ref.boost__json__string.assign.overload4 `more...`]]``
|
||
|
||
string&
|
||
``[link json.ref.boost__json__string.assign.overload5 assign]``(
|
||
char const* s);
|
||
``[''''»''' [link json.ref.boost__json__string.assign.overload5 `more...`]]``
|
||
|
||
template<
|
||
class InputIt>
|
||
string&
|
||
``[link json.ref.boost__json__string.assign.overload6 assign]``(
|
||
InputIt first,
|
||
InputIt last);
|
||
``[''''»''' [link json.ref.boost__json__string.assign.overload6 `more...`]]``
|
||
|
||
string&
|
||
``[link json.ref.boost__json__string.assign.overload7 assign]``(
|
||
string_view s);
|
||
``[''''»''' [link json.ref.boost__json__string.assign.overload7 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::assign (1 of 7 overloads)]
|
||
|
||
Assign characters to a string.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
assign(
|
||
std::size_t count,
|
||
char ch);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace the contents with `count` copies of character `ch`.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear in `count`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`count`
|
||
]
|
||
[
|
||
The size of the resulting string.
|
||
]
|
||
]
|
||
[
|
||
[`ch`
|
||
]
|
||
[
|
||
The value to initialize characters of the string with.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`count > max_size()`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::assign (2 of 7 overloads)]
|
||
|
||
Assign characters to a string.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
assign(
|
||
string const& other);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace the contents with a copy of `other`.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear in `other.size()`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The string to use as a source to copy from.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 string::assign (3 of 7 overloads)]
|
||
|
||
Assign characters to a string.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
assign(
|
||
string&& other);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace the contents with those of `other` using move semantics.
|
||
|
||
* If `*other.storage() == *this->storage()`, ownership of the underlying memory is transferred in constant time, with no possibility of exceptions. After construction, the moved-from string behaves as if newly constructed with its current [link json.ref.boost__json__memory_resource `memory_resource`], otherwise
|
||
|
||
* If `*other.storage() != *this->storage()`, a copy of the characters in `other` is made. In this case, the moved-from container is not changed.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant or linear in `other.size()`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The string to assign from.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 string::assign (4 of 7 overloads)]
|
||
|
||
Assign characters to a string.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
assign(
|
||
char const* s,
|
||
std::size_t count);
|
||
```
|
||
|
||
[heading Description]
|
||
Replaces the contents with copies of the characters in the range `{s, s+count)`. This range can contain null characters.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear in `count`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`count`
|
||
]
|
||
[
|
||
The number of characters to copy.
|
||
]
|
||
]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
A pointer to a character string used to copy from.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`count > max_size()`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload5 string::assign (5 of 7 overloads)]
|
||
|
||
Assign characters to a string.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
assign(
|
||
char const* s);
|
||
```
|
||
|
||
[heading Description]
|
||
Replaces the contents with those of the null terminated string pointed to by `s`. The length of the string is determined by the first null character.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear in `strlen(s)`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Remarks]
|
||
|
||
Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
A pointer to a character string used to copy from.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`strlen(s) > max_size()`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload6 string::assign (6 of 7 overloads)]
|
||
|
||
Assign characters to a string.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class InputIt>
|
||
string&
|
||
assign(
|
||
InputIt first,
|
||
InputIt last);
|
||
```
|
||
|
||
[heading Description]
|
||
Replaces the contents with copies of characters in the range `{first, last)`.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear in `std::distance(first, last)`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Template Parameters]
|
||
[table [[Type][Description]]
|
||
[
|
||
[`InputIt`
|
||
]
|
||
[
|
||
The type of the iterators.
|
||
]
|
||
]
|
||
]
|
||
[heading Constraints]
|
||
|
||
`InputIt`satisfies [*InputIterator].
|
||
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`first`
|
||
]
|
||
[
|
||
An input iterator pointing to the first character to insert, or pointing to the end of the range.
|
||
]
|
||
]
|
||
[
|
||
[`last`
|
||
]
|
||
[
|
||
An input iterator pointing to the end of the range.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`std::distance(first, last) > max_size()`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload7 string::assign (7 of 7 overloads)]
|
||
|
||
Assign characters to a string.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
assign(
|
||
string_view s);
|
||
```
|
||
|
||
[heading Description]
|
||
Replaces the contents with those of a string view. This view can contain null characters.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear in `s.size()`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The string view to copy from.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`s.size() > max_size()`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:storage string::storage]
|
||
[indexterm2 storage..string]
|
||
|
||
|
||
Return the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
[heading Synopsis]
|
||
```
|
||
storage_ptr const&
|
||
storage() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This returns the [link json.ref.boost__json__memory_resource `memory_resource`] used by the container.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[heading Exception Safety]
|
||
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:get_allocator string::get_allocator]
|
||
[indexterm2 get_allocator..string]
|
||
|
||
|
||
Return the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
[heading Synopsis]
|
||
```
|
||
allocator_type
|
||
get_allocator() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns an instance of [link json.ref.boost__json__polymorphic_allocator `polymorphic_allocator`] constructed from the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[heading Exception Safety]
|
||
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:at string::at]
|
||
[indexterm2 at..string]
|
||
|
||
|
||
Return a character with bounds checking.
|
||
```
|
||
char&
|
||
``[link json.ref.boost__json__string.at.overload1 at]``(
|
||
std::size_t pos);
|
||
``[''''»''' [link json.ref.boost__json__string.at.overload1 `more...`]]``
|
||
|
||
char const&
|
||
``[link json.ref.boost__json__string.at.overload2 at]``(
|
||
std::size_t pos) const;
|
||
``[''''»''' [link json.ref.boost__json__string.at.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::at (1 of 2 overloads)]
|
||
|
||
Return a character with bounds checking.
|
||
[heading Synopsis]
|
||
```
|
||
char&
|
||
at(
|
||
std::size_t pos);
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a reference to the character specified at location `pos`.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
A zero-based index to access.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::out_of_range`
|
||
]
|
||
[
|
||
`pos >= size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::at (2 of 2 overloads)]
|
||
|
||
Return a character with bounds checking.
|
||
[heading Synopsis]
|
||
```
|
||
char const&
|
||
at(
|
||
std::size_t pos) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a reference to the character specified at location `pos`.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
A zero-based index to access.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::out_of_range`
|
||
]
|
||
[
|
||
`pos >= size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:operator_lb__rb_ string::operator\[\]]
|
||
[indexterm2 operator\[\]..string]
|
||
|
||
|
||
Return a character without bounds checking.
|
||
```
|
||
char&
|
||
``[link json.ref.boost__json__string.operator_lb__rb_.overload1 operator\[\]]``(
|
||
std::size_t pos);
|
||
``[''''»''' [link json.ref.boost__json__string.operator_lb__rb_.overload1 `more...`]]``
|
||
|
||
const char&
|
||
``[link json.ref.boost__json__string.operator_lb__rb_.overload2 operator\[\]]``(
|
||
std::size_t pos) const;
|
||
``[''''»''' [link json.ref.boost__json__string.operator_lb__rb_.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::operator\[\] (1 of 2 overloads)]
|
||
|
||
Return a character without bounds checking.
|
||
[heading Synopsis]
|
||
```
|
||
char&
|
||
operator\[\](
|
||
std::size_t pos);
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a reference to the character specified at location `pos`.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[heading Precondition]
|
||
|
||
```
|
||
pos >= size
|
||
```
|
||
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
A zero-based index to access.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::operator\[\] (2 of 2 overloads)]
|
||
|
||
Return a character without bounds checking.
|
||
[heading Synopsis]
|
||
```
|
||
const char&
|
||
operator\[\](
|
||
std::size_t pos) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a reference to the character specified at location `pos`.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[heading Precondition]
|
||
|
||
```
|
||
pos >= size
|
||
```
|
||
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
A zero-based index to access.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:front string::front]
|
||
[indexterm2 front..string]
|
||
|
||
|
||
Return the first character.
|
||
```
|
||
char&
|
||
``[link json.ref.boost__json__string.front.overload1 front]``();
|
||
``[''''»''' [link json.ref.boost__json__string.front.overload1 `more...`]]``
|
||
|
||
char const&
|
||
``[link json.ref.boost__json__string.front.overload2 front]``() const;
|
||
``[''''»''' [link json.ref.boost__json__string.front.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::front (1 of 2 overloads)]
|
||
|
||
Return the first character.
|
||
[heading Synopsis]
|
||
```
|
||
char&
|
||
front();
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a reference to the first character.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[heading Precondition]
|
||
|
||
```
|
||
not empty()
|
||
```
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::front (2 of 2 overloads)]
|
||
|
||
Return the first character.
|
||
[heading Synopsis]
|
||
```
|
||
char const&
|
||
front() const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a reference to the first character.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[heading Precondition]
|
||
|
||
```
|
||
not empty()
|
||
```
|
||
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:back string::back]
|
||
[indexterm2 back..string]
|
||
|
||
|
||
Return the last character.
|
||
```
|
||
char&
|
||
``[link json.ref.boost__json__string.back.overload1 back]``();
|
||
``[''''»''' [link json.ref.boost__json__string.back.overload1 `more...`]]``
|
||
|
||
char const&
|
||
``[link json.ref.boost__json__string.back.overload2 back]``() const;
|
||
``[''''»''' [link json.ref.boost__json__string.back.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::back (1 of 2 overloads)]
|
||
|
||
Return the last character.
|
||
[heading Synopsis]
|
||
```
|
||
char&
|
||
back();
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a reference to the last character.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[heading Precondition]
|
||
|
||
```
|
||
not empty()
|
||
```
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::back (2 of 2 overloads)]
|
||
|
||
Return the last character.
|
||
[heading Synopsis]
|
||
```
|
||
char const&
|
||
back() const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a reference to the last character.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[heading Precondition]
|
||
|
||
```
|
||
not empty()
|
||
```
|
||
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:data string::data]
|
||
[indexterm2 data..string]
|
||
|
||
|
||
Return the underlying character array directly.
|
||
```
|
||
char*
|
||
``[link json.ref.boost__json__string.data.overload1 data]``();
|
||
``[''''»''' [link json.ref.boost__json__string.data.overload1 `more...`]]``
|
||
|
||
char const*
|
||
``[link json.ref.boost__json__string.data.overload2 data]``() const;
|
||
``[''''»''' [link json.ref.boost__json__string.data.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::data (1 of 2 overloads)]
|
||
|
||
Return the underlying character array directly.
|
||
[heading Synopsis]
|
||
```
|
||
char*
|
||
data();
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a pointer to the underlying array serving as storage. The value returned is such that the range `{data(), data()+size())` is always a valid range, even if the container is empty.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[heading Remarks]
|
||
The value returned from this function is never equal to `nullptr`.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::data (2 of 2 overloads)]
|
||
|
||
Return the underlying character array directly.
|
||
[heading Synopsis]
|
||
```
|
||
char const*
|
||
data() const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a pointer to the underlying array serving as storage.
|
||
|
||
[heading Remarks]
|
||
The value returned is such that the range `{data(), data() + size())` is always a valid range, even if the container is empty. The value returned from this function is never equal to `nullptr`.
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:c_str string::c_str]
|
||
[indexterm2 c_str..string]
|
||
|
||
|
||
Return the underlying character array directly.
|
||
[heading Synopsis]
|
||
```
|
||
char const*
|
||
c_str() const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a pointer to the underlying array serving as storage. The value returned is such that the range `{c_str(), c_str() + size()}` is always a valid range, even if the container is empty.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[heading Remarks]
|
||
The value returned from this function is never equal to `nullptr`.
|
||
|
||
[endsect]
|
||
|
||
[section:operator_string_view string::operator string_view]
|
||
[indexterm2 operator string_view..string]
|
||
|
||
|
||
Convert to a `string_view` referring to the string.
|
||
[heading Synopsis]
|
||
```
|
||
operator string_view() const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a string view to the underlying character string. The size of the view does not include the null terminator.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[endsect]
|
||
|
||
[section:begin string::begin]
|
||
[indexterm2 begin..string]
|
||
|
||
|
||
Return an iterator to the beginning.
|
||
```
|
||
iterator
|
||
``[link json.ref.boost__json__string.begin.overload1 begin]``();
|
||
``[''''»''' [link json.ref.boost__json__string.begin.overload1 `more...`]]``
|
||
|
||
const_iterator
|
||
``[link json.ref.boost__json__string.begin.overload2 begin]``() const;
|
||
``[''''»''' [link json.ref.boost__json__string.begin.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::begin (1 of 2 overloads)]
|
||
|
||
Return an iterator to the beginning.
|
||
[heading Synopsis]
|
||
```
|
||
iterator
|
||
begin();
|
||
```
|
||
|
||
[heading Description]
|
||
If the container is empty, [link json.ref.boost__json__string.end `end()`] is returned.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::begin (2 of 2 overloads)]
|
||
|
||
Return an iterator to the beginning.
|
||
[heading Synopsis]
|
||
```
|
||
const_iterator
|
||
begin() const;
|
||
```
|
||
|
||
[heading Description]
|
||
If the container is empty, [link json.ref.boost__json__string.end `end()`] is returned.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:cbegin string::cbegin]
|
||
[indexterm2 cbegin..string]
|
||
|
||
|
||
Return an iterator to the beginning.
|
||
[heading Synopsis]
|
||
```
|
||
const_iterator
|
||
cbegin() const;
|
||
```
|
||
|
||
[heading Description]
|
||
If the container is empty, [link json.ref.boost__json__string.cend `cend()`] is returned.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:end string::end]
|
||
[indexterm2 end..string]
|
||
|
||
|
||
Return an iterator to the end.
|
||
```
|
||
iterator
|
||
``[link json.ref.boost__json__string.end.overload1 end]``();
|
||
``[''''»''' [link json.ref.boost__json__string.end.overload1 `more...`]]``
|
||
|
||
const_iterator
|
||
``[link json.ref.boost__json__string.end.overload2 end]``() const;
|
||
``[''''»''' [link json.ref.boost__json__string.end.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::end (1 of 2 overloads)]
|
||
|
||
Return an iterator to the end.
|
||
[heading Synopsis]
|
||
```
|
||
iterator
|
||
end();
|
||
```
|
||
|
||
[heading Description]
|
||
Returns an iterator to the character following the last character of the string. This character acts as a placeholder, attempting to access it results in undefined behavior.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::end (2 of 2 overloads)]
|
||
|
||
Return an iterator to the end.
|
||
[heading Synopsis]
|
||
```
|
||
const_iterator
|
||
end() const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns an iterator to the character following the last character of the string. This character acts as a placeholder, attempting to access it results in undefined behavior.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:cend string::cend]
|
||
[indexterm2 cend..string]
|
||
|
||
|
||
Return an iterator to the end.
|
||
[heading Synopsis]
|
||
```
|
||
const_iterator
|
||
cend() const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns an iterator to the character following the last character of the string. This character acts as a placeholder, attempting to access it results in undefined behavior.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:rbegin string::rbegin]
|
||
[indexterm2 rbegin..string]
|
||
|
||
|
||
Return a reverse iterator to the first character of the reversed container.
|
||
```
|
||
reverse_iterator
|
||
``[link json.ref.boost__json__string.rbegin.overload1 rbegin]``();
|
||
``[''''»''' [link json.ref.boost__json__string.rbegin.overload1 `more...`]]``
|
||
|
||
const_reverse_iterator
|
||
``[link json.ref.boost__json__string.rbegin.overload2 rbegin]``() const;
|
||
``[''''»''' [link json.ref.boost__json__string.rbegin.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::rbegin (1 of 2 overloads)]
|
||
|
||
Return a reverse iterator to the first character of the reversed container.
|
||
[heading Synopsis]
|
||
```
|
||
reverse_iterator
|
||
rbegin();
|
||
```
|
||
|
||
[heading Description]
|
||
Returns the pointed-to character that corresponds to the last character of the non-reversed container. If the container is empty, [link json.ref.boost__json__string.rend `rend()`] is returned.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::rbegin (2 of 2 overloads)]
|
||
|
||
Return a reverse iterator to the first character of the reversed container.
|
||
[heading Synopsis]
|
||
```
|
||
const_reverse_iterator
|
||
rbegin() const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns the pointed-to character that corresponds to the last character of the non-reversed container. If the container is empty, [link json.ref.boost__json__string.rend `rend()`] is returned.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:crbegin string::crbegin]
|
||
[indexterm2 crbegin..string]
|
||
|
||
|
||
Return a reverse iterator to the first character of the reversed container.
|
||
[heading Synopsis]
|
||
```
|
||
const_reverse_iterator
|
||
crbegin() const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns the pointed-to character that corresponds to the last character of the non-reversed container. If the container is empty, [link json.ref.boost__json__string.crend `crend()`] is returned.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:rend string::rend]
|
||
[indexterm2 rend..string]
|
||
|
||
|
||
Return a reverse iterator to the character following the last character of the reversed container.
|
||
```
|
||
reverse_iterator
|
||
``[link json.ref.boost__json__string.rend.overload1 rend]``();
|
||
``[''''»''' [link json.ref.boost__json__string.rend.overload1 `more...`]]``
|
||
|
||
const_reverse_iterator
|
||
``[link json.ref.boost__json__string.rend.overload2 rend]``() const;
|
||
``[''''»''' [link json.ref.boost__json__string.rend.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::rend (1 of 2 overloads)]
|
||
|
||
Return a reverse iterator to the character following the last character of the reversed container.
|
||
[heading Synopsis]
|
||
```
|
||
reverse_iterator
|
||
rend();
|
||
```
|
||
|
||
[heading Description]
|
||
Returns the pointed-to character that corresponds to the character preceding the first character of the non-reversed container. This character acts as a placeholder, attempting to access it results in undefined behavior.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::rend (2 of 2 overloads)]
|
||
|
||
Return a reverse iterator to the character following the last character of the reversed container.
|
||
[heading Synopsis]
|
||
```
|
||
const_reverse_iterator
|
||
rend() const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns the pointed-to character that corresponds to the character preceding the first character of the non-reversed container. This character acts as a placeholder, attempting to access it results in undefined behavior.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:crend string::crend]
|
||
[indexterm2 crend..string]
|
||
|
||
|
||
Return a reverse iterator to the character following the last character of the reversed container.
|
||
[heading Synopsis]
|
||
```
|
||
const_reverse_iterator
|
||
crend() const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns the pointed-to character that corresponds to the character preceding the first character of the non-reversed container. This character acts as a placeholder, attempting to access it results in undefined behavior.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:empty string::empty]
|
||
[indexterm2 empty..string]
|
||
|
||
|
||
Check if the string has no characters.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
empty() const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns `true` if there are no characters in the string, i.e. [link json.ref.boost__json__string.size `size()`] returns 0.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[endsect]
|
||
|
||
[section:size string::size]
|
||
[indexterm2 size..string]
|
||
|
||
|
||
Return the number of characters in the string.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
size() const;
|
||
```
|
||
|
||
[heading Description]
|
||
The value returned does not include the null terminator, which is always present.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[endsect]
|
||
|
||
[section:capacity string::capacity]
|
||
[indexterm2 capacity..string]
|
||
|
||
|
||
Return the number of characters that can be held without a reallocation.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
capacity() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This number represents the largest number of characters the currently allocated storage can contain. This number may be larger than the value returned by [link json.ref.boost__json__string.size `size()`].
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[endsect]
|
||
|
||
[section:reserve string::reserve]
|
||
[indexterm2 reserve..string]
|
||
|
||
|
||
Increase the capacity to at least a certain amount.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
reserve(
|
||
std::size_t new_capacity);
|
||
```
|
||
|
||
[heading Description]
|
||
This increases the capacity of the array to a value that is greater than or equal to `new_capacity`. If `new_capacity > capacity()`, new memory is allocated. Otherwise, the call has no effect. The number of elements and therefore the [link json.ref.boost__json__string.size `size()`] of the container is not changed.
|
||
|
||
[heading Complexity]
|
||
|
||
At most, linear in [link json.ref.boost__json__string.size `size()`].
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Remarks]
|
||
|
||
If new memory is allocated, all iterators including any past-the-end iterators, and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`new_capacity`
|
||
]
|
||
[
|
||
The new capacity of the array.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`new_capacity > max_size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:shrink_to_fit string::shrink_to_fit]
|
||
[indexterm2 shrink_to_fit..string]
|
||
|
||
|
||
Request the removal of unused capacity.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
shrink_to_fit();
|
||
```
|
||
|
||
[heading Description]
|
||
This performs a non-binding request to reduce [link json.ref.boost__json__string.capacity `capacity()`] to [link json.ref.boost__json__string.size `size()`]. The request may or may not be fulfilled.
|
||
|
||
[heading Complexity]
|
||
|
||
At most, linear in [link json.ref.boost__json__string.size `size()`].
|
||
|
||
[heading Remarks]
|
||
If reallocation occurs, all iterators including any past-the-end iterators, and all references to characters are invalidated. Otherwise, no iterators or references are invalidated.
|
||
|
||
[endsect]
|
||
|
||
[section:clear string::clear]
|
||
[indexterm2 clear..string]
|
||
|
||
|
||
Clear the contents.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
clear();
|
||
```
|
||
|
||
[heading Description]
|
||
Erases all characters from the string. After this call, [link json.ref.boost__json__string.size `size()`] returns zero but [link json.ref.boost__json__string.capacity `capacity()`] is unchanged.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear in [link json.ref.boost__json__string.size `size()`].
|
||
|
||
[heading Remarks]
|
||
All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated.
|
||
|
||
[endsect]
|
||
|
||
[section:insert string::insert]
|
||
[indexterm2 insert..string]
|
||
|
||
|
||
Insert a string.
|
||
```
|
||
string&
|
||
``[link json.ref.boost__json__string.insert.overload1 insert]``(
|
||
std::size_t pos,
|
||
string_view sv);
|
||
``[''''»''' [link json.ref.boost__json__string.insert.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Insert a character.
|
||
```
|
||
string&
|
||
``[link json.ref.boost__json__string.insert.overload2 insert]``(
|
||
std::size_t pos,
|
||
std::size_t count,
|
||
char ch);
|
||
``[''''»''' [link json.ref.boost__json__string.insert.overload2 `more...`]]``
|
||
|
||
string&
|
||
``[link json.ref.boost__json__string.insert.overload3 insert]``(
|
||
size_type pos,
|
||
char ch);
|
||
``[''''»''' [link json.ref.boost__json__string.insert.overload3 `more...`]]``
|
||
```
|
||
|
||
|
||
Insert a range of characters.
|
||
```
|
||
template<
|
||
class InputIt>
|
||
string&
|
||
``[link json.ref.boost__json__string.insert.overload4 insert]``(
|
||
size_type pos,
|
||
InputIt first,
|
||
InputIt last);
|
||
``[''''»''' [link json.ref.boost__json__string.insert.overload4 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::insert (1 of 4 overloads)]
|
||
|
||
Insert a string.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
insert(
|
||
std::size_t pos,
|
||
string_view sv);
|
||
```
|
||
|
||
[heading Description]
|
||
Inserts the `string_view``sv` at the position `pos`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Remarks]
|
||
All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated.
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index to insert at.
|
||
]
|
||
]
|
||
[
|
||
[`sv`
|
||
]
|
||
[
|
||
The `string_view` to insert.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`size() + s.size() > max_size()`
|
||
]
|
||
]
|
||
[
|
||
[`std::out_of_range`
|
||
]
|
||
[
|
||
`pos > size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::insert (2 of 4 overloads)]
|
||
|
||
Insert a character.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
insert(
|
||
std::size_t pos,
|
||
std::size_t count,
|
||
char ch);
|
||
```
|
||
|
||
[heading Description]
|
||
Inserts `count` copies of `ch` at the position `pos`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Remarks]
|
||
All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated.
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index to insert at.
|
||
]
|
||
]
|
||
[
|
||
[`count`
|
||
]
|
||
[
|
||
The number of characters to insert.
|
||
]
|
||
]
|
||
[
|
||
[`ch`
|
||
]
|
||
[
|
||
The character to insert.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`size() + count > max_size()`
|
||
]
|
||
]
|
||
[
|
||
[`std::out_of_range`
|
||
]
|
||
[
|
||
`pos > size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 string::insert (3 of 4 overloads)]
|
||
|
||
Insert a character.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
insert(
|
||
size_type pos,
|
||
char ch);
|
||
```
|
||
|
||
[heading Description]
|
||
Inserts the character `ch` before the character at index `pos`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Remarks]
|
||
All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated.
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index to insert at.
|
||
]
|
||
]
|
||
[
|
||
[`ch`
|
||
]
|
||
[
|
||
The character to insert.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`size() + 1 > max_size()`
|
||
]
|
||
]
|
||
[
|
||
[`std::out_of_range`
|
||
]
|
||
[
|
||
`pos > size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 string::insert (4 of 4 overloads)]
|
||
|
||
Insert a range of characters.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class InputIt>
|
||
string&
|
||
insert(
|
||
size_type pos,
|
||
InputIt first,
|
||
InputIt last);
|
||
```
|
||
|
||
[heading Description]
|
||
Inserts characters from the range `{first, last)` before the character at index `pos`.
|
||
|
||
[heading Precondition]
|
||
|
||
`{first, last)`is a valid range.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Remarks]
|
||
All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated.
|
||
[heading Template Parameters]
|
||
[table [[Type][Description]]
|
||
[
|
||
[`InputIt`
|
||
]
|
||
[
|
||
The type of the iterators.
|
||
]
|
||
]
|
||
]
|
||
[heading Constraints]
|
||
|
||
`InputIt`satisfies [*InputIterator].
|
||
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index to insert at.
|
||
]
|
||
]
|
||
[
|
||
[`first`
|
||
]
|
||
[
|
||
The beginning of the character range.
|
||
]
|
||
]
|
||
[
|
||
[`last`
|
||
]
|
||
[
|
||
The end of the character range.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`size() + insert_count > max_size()`
|
||
]
|
||
]
|
||
[
|
||
[`std::out_of_range`
|
||
]
|
||
[
|
||
`pos > size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:erase string::erase]
|
||
[indexterm2 erase..string]
|
||
|
||
|
||
Erase characters from the string.
|
||
```
|
||
string&
|
||
``[link json.ref.boost__json__string.erase.overload1 erase]``(
|
||
std::size_t pos = 0,
|
||
std::size_t count = ``[link json.ref.boost__json__string.npos npos]``);
|
||
``[''''»''' [link json.ref.boost__json__string.erase.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Erase a character from the string.
|
||
```
|
||
iterator
|
||
``[link json.ref.boost__json__string.erase.overload2 erase]``(
|
||
const_iterator pos);
|
||
``[''''»''' [link json.ref.boost__json__string.erase.overload2 `more...`]]``
|
||
```
|
||
|
||
|
||
Erase a range from the string.
|
||
```
|
||
iterator
|
||
``[link json.ref.boost__json__string.erase.overload3 erase]``(
|
||
const_iterator first,
|
||
const_iterator last);
|
||
``[''''»''' [link json.ref.boost__json__string.erase.overload3 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::erase (1 of 3 overloads)]
|
||
|
||
Erase characters from the string.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
erase(
|
||
std::size_t pos = 0,
|
||
std::size_t count = ``[link json.ref.boost__json__string.npos npos]``);
|
||
```
|
||
|
||
[heading Description]
|
||
Erases `num` characters from the string, starting at `pos`. `num` is determined as the smaller of `count` and `size() - pos`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Remarks]
|
||
All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated.
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index to erase at. The default argument for this parameter is `0`.
|
||
]
|
||
]
|
||
[
|
||
[`count`
|
||
]
|
||
[
|
||
The number of characters to erase. The default argument for this parameter is [link json.ref.boost__json__string.npos `npos`].
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::out_of_range`
|
||
]
|
||
[
|
||
`pos > size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::erase (2 of 3 overloads)]
|
||
|
||
Erase a character from the string.
|
||
[heading Synopsis]
|
||
```
|
||
iterator
|
||
erase(
|
||
const_iterator pos);
|
||
```
|
||
|
||
[heading Description]
|
||
Erases the character at `pos`.
|
||
|
||
[heading Precondition]
|
||
|
||
```
|
||
pos >= data() && pos <= data() + size()
|
||
```
|
||
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Remarks]
|
||
All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated.
|
||
[heading Return Value]
|
||
An iterator referring to character immediately following the erased character, or [link json.ref.boost__json__string.end `end()`] if one does not exist.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
An iterator referring to the character to erase.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 string::erase (3 of 3 overloads)]
|
||
|
||
Erase a range from the string.
|
||
[heading Synopsis]
|
||
```
|
||
iterator
|
||
erase(
|
||
const_iterator first,
|
||
const_iterator last);
|
||
```
|
||
|
||
[heading Description]
|
||
Erases the characters in the range `{first, last)`.
|
||
|
||
[heading Precondition]
|
||
|
||
`{first, last}`shall be valid within
|
||
```
|
||
{data(), data() + size()}
|
||
```
|
||
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Remarks]
|
||
All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated.
|
||
[heading Return Value]
|
||
An iterator referring to the character `last` previously referred to, or [link json.ref.boost__json__string.end `end()`] if one does not exist.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`first`
|
||
]
|
||
[
|
||
An iterator representing the first character to erase.
|
||
]
|
||
]
|
||
[
|
||
[`last`
|
||
]
|
||
[
|
||
An iterator one past the last character to erase.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:push_back string::push_back]
|
||
[indexterm2 push_back..string]
|
||
|
||
|
||
Append a character.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
push_back(
|
||
char ch);
|
||
```
|
||
|
||
[heading Description]
|
||
Appends a character to the end of the string.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`ch`
|
||
]
|
||
[
|
||
The character to append.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`size() + 1 > max_size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:pop_back string::pop_back]
|
||
[indexterm2 pop_back..string]
|
||
|
||
|
||
Remove the last character.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
pop_back();
|
||
```
|
||
|
||
[heading Description]
|
||
Removes a character from the end of the string.
|
||
|
||
[heading Precondition]
|
||
|
||
```
|
||
not empty()
|
||
```
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:append string::append]
|
||
[indexterm2 append..string]
|
||
|
||
|
||
Append characters to the string.
|
||
```
|
||
string&
|
||
``[link json.ref.boost__json__string.append.overload1 append]``(
|
||
std::size_t count,
|
||
char ch);
|
||
``[''''»''' [link json.ref.boost__json__string.append.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Append a string to the string.
|
||
```
|
||
string&
|
||
``[link json.ref.boost__json__string.append.overload2 append]``(
|
||
string_view sv);
|
||
``[''''»''' [link json.ref.boost__json__string.append.overload2 `more...`]]``
|
||
```
|
||
|
||
|
||
Append a range of characters.
|
||
```
|
||
template<
|
||
class InputIt>
|
||
string&
|
||
``[link json.ref.boost__json__string.append.overload3 append]``(
|
||
InputIt first,
|
||
InputIt last);
|
||
``[''''»''' [link json.ref.boost__json__string.append.overload3 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::append (1 of 3 overloads)]
|
||
|
||
Append characters to the string.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
append(
|
||
std::size_t count,
|
||
char ch);
|
||
```
|
||
|
||
[heading Description]
|
||
Appends `count` copies of `ch` to the end of the string.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`count`
|
||
]
|
||
[
|
||
The number of characters to append.
|
||
]
|
||
]
|
||
[
|
||
[`ch`
|
||
]
|
||
[
|
||
The character to append.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`size() + count > max_size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::append (2 of 3 overloads)]
|
||
|
||
Append a string to the string.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
append(
|
||
string_view sv);
|
||
```
|
||
|
||
[heading Description]
|
||
Appends `sv` the end of the string.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sv`
|
||
]
|
||
[
|
||
The `string_view` to append.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`size() + s.size() > max_size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 string::append (3 of 3 overloads)]
|
||
|
||
Append a range of characters.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class InputIt>
|
||
string&
|
||
append(
|
||
InputIt first,
|
||
InputIt last);
|
||
```
|
||
|
||
[heading Description]
|
||
Appends characters from the range `{first, last)` to the end of the string.
|
||
|
||
[heading Precondition]
|
||
|
||
`{first, last)`shall be a valid range
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Template Parameters]
|
||
[table [[Type][Description]]
|
||
[
|
||
[`InputIt`
|
||
]
|
||
[
|
||
The type of the iterators.
|
||
]
|
||
]
|
||
]
|
||
[heading Constraints]
|
||
|
||
`InputIt`satisfies [*InputIterator].
|
||
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`first`
|
||
]
|
||
[
|
||
An iterator representing the first character to append.
|
||
]
|
||
]
|
||
[
|
||
[`last`
|
||
]
|
||
[
|
||
An iterator one past the last character to append.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`size() + insert_count > max_size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:operator_plus__eq_ string::operator+=]
|
||
[indexterm2 operator+=..string]
|
||
|
||
|
||
Append characters from a string.
|
||
```
|
||
string&
|
||
``[link json.ref.boost__json__string.operator_plus__eq_.overload1 operator+=]``(
|
||
string_view sv);
|
||
``[''''»''' [link json.ref.boost__json__string.operator_plus__eq_.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Append a character.
|
||
```
|
||
string&
|
||
``[link json.ref.boost__json__string.operator_plus__eq_.overload2 operator+=]``(
|
||
char ch);
|
||
``[''''»''' [link json.ref.boost__json__string.operator_plus__eq_.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::operator+= (1 of 2 overloads)]
|
||
|
||
Append characters from a string.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
operator+=(
|
||
string_view sv);
|
||
```
|
||
|
||
[heading Description]
|
||
Appends `{sv.begin(), sv.end())` to the end of the string.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sv`
|
||
]
|
||
[
|
||
The `string_view` to append.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`size() + sv.size() > max_size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::operator+= (2 of 2 overloads)]
|
||
|
||
Append a character.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
operator+=(
|
||
char ch);
|
||
```
|
||
|
||
[heading Description]
|
||
Appends a character to the end of the string.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`ch`
|
||
]
|
||
[
|
||
The character to append.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`size() + 1 > max_size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:compare string::compare]
|
||
[indexterm2 compare..string]
|
||
|
||
|
||
Compare a string with the string.
|
||
[heading Synopsis]
|
||
```
|
||
int
|
||
compare(
|
||
string_view sv) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Let `comp` be `std::char_traits<char>compare(data(), sv.data(), std::min(size(), sv.size())`. If `comp != 0`, then the result is `comp`. Otherwise, the result is `0` if `size() == sv.size()`, `-1` if `size() < sv.size()`, and `1` otherwise.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear.
|
||
|
||
[heading Return Value]
|
||
The result of lexicographically comparing the characters of `sv` and the string.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sv`
|
||
]
|
||
[
|
||
The `string_view` to compare.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:starts_with string::starts_with]
|
||
[indexterm2 starts_with..string]
|
||
|
||
|
||
Return whether the string begins with a string.
|
||
```
|
||
bool
|
||
``[link json.ref.boost__json__string.starts_with.overload1 starts_with]``(
|
||
string_view s) const;
|
||
``[''''»''' [link json.ref.boost__json__string.starts_with.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Return whether the string begins with a character.
|
||
```
|
||
bool
|
||
``[link json.ref.boost__json__string.starts_with.overload2 starts_with]``(
|
||
char ch) const;
|
||
``[''''»''' [link json.ref.boost__json__string.starts_with.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::starts_with (1 of 2 overloads)]
|
||
|
||
Return whether the string begins with a string.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
starts_with(
|
||
string_view s) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns `true` if the string begins with `s`, and `false` otherwise.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The `string_view` to check for.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::starts_with (2 of 2 overloads)]
|
||
|
||
Return whether the string begins with a character.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
starts_with(
|
||
char ch) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns `true` if the string begins with `ch`, and `false` otherwise.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`ch`
|
||
]
|
||
[
|
||
The character to check for.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:ends_with string::ends_with]
|
||
[indexterm2 ends_with..string]
|
||
|
||
|
||
Return whether the string end with a string.
|
||
```
|
||
bool
|
||
``[link json.ref.boost__json__string.ends_with.overload1 ends_with]``(
|
||
string_view s) const;
|
||
``[''''»''' [link json.ref.boost__json__string.ends_with.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Return whether the string ends with a character.
|
||
```
|
||
bool
|
||
``[link json.ref.boost__json__string.ends_with.overload2 ends_with]``(
|
||
char ch) const;
|
||
``[''''»''' [link json.ref.boost__json__string.ends_with.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::ends_with (1 of 2 overloads)]
|
||
|
||
Return whether the string end with a string.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
ends_with(
|
||
string_view s) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns `true` if the string end with `s`, and `false` otherwise.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The string to check for.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::ends_with (2 of 2 overloads)]
|
||
|
||
Return whether the string ends with a character.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
ends_with(
|
||
char ch) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns `true` if the string ends with `ch`, and `false` otherwise.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`ch`
|
||
]
|
||
[
|
||
The character to check for.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:replace string::replace]
|
||
[indexterm2 replace..string]
|
||
|
||
|
||
Replace a substring with a string.
|
||
```
|
||
string&
|
||
``[link json.ref.boost__json__string.replace.overload1 replace]``(
|
||
std::size_t pos,
|
||
std::size_t count,
|
||
string_view sv);
|
||
``[''''»''' [link json.ref.boost__json__string.replace.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Replace a range with a string.
|
||
```
|
||
string&
|
||
``[link json.ref.boost__json__string.replace.overload2 replace]``(
|
||
const_iterator first,
|
||
const_iterator last,
|
||
string_view sv);
|
||
``[''''»''' [link json.ref.boost__json__string.replace.overload2 `more...`]]``
|
||
```
|
||
|
||
|
||
Replace a range with a range.
|
||
```
|
||
template<
|
||
class InputIt>
|
||
string&
|
||
``[link json.ref.boost__json__string.replace.overload3 replace]``(
|
||
const_iterator first,
|
||
const_iterator last,
|
||
InputIt first2,
|
||
InputIt last2);
|
||
``[''''»''' [link json.ref.boost__json__string.replace.overload3 `more...`]]``
|
||
```
|
||
|
||
|
||
Replace a substring with copies of a character.
|
||
```
|
||
string&
|
||
``[link json.ref.boost__json__string.replace.overload4 replace]``(
|
||
std::size_t pos,
|
||
std::size_t count,
|
||
std::size_t count2,
|
||
char ch);
|
||
``[''''»''' [link json.ref.boost__json__string.replace.overload4 `more...`]]``
|
||
```
|
||
|
||
|
||
Replace a range with copies of a character.
|
||
```
|
||
string&
|
||
``[link json.ref.boost__json__string.replace.overload5 replace]``(
|
||
const_iterator first,
|
||
const_iterator last,
|
||
std::size_t count,
|
||
char ch);
|
||
``[''''»''' [link json.ref.boost__json__string.replace.overload5 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::replace (1 of 5 overloads)]
|
||
|
||
Replace a substring with a string.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
replace(
|
||
std::size_t pos,
|
||
std::size_t count,
|
||
string_view sv);
|
||
```
|
||
|
||
[heading Description]
|
||
Replaces `rcount` characters starting at index `pos` with those of `sv`, where `rcount` is `std::min(count, size() - pos)`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Remarks]
|
||
All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated.
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index to replace at.
|
||
]
|
||
]
|
||
[
|
||
[`count`
|
||
]
|
||
[
|
||
The number of characters to replace.
|
||
]
|
||
]
|
||
[
|
||
[`sv`
|
||
]
|
||
[
|
||
The `string_view` to replace with.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`size() + (sv.size() - rcount) > max_size()`
|
||
]
|
||
]
|
||
[
|
||
[`std::out_of_range`
|
||
]
|
||
[
|
||
`pos > size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::replace (2 of 5 overloads)]
|
||
|
||
Replace a range with a string.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
replace(
|
||
const_iterator first,
|
||
const_iterator last,
|
||
string_view sv);
|
||
```
|
||
|
||
[heading Description]
|
||
Replaces the characters in the range `{first, last)` with those of `sv`.
|
||
|
||
[heading Precondition]
|
||
|
||
`{first, last)`is a valid range.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Remarks]
|
||
All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated.
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`first`
|
||
]
|
||
[
|
||
An iterator referring to the first character to replace.
|
||
]
|
||
]
|
||
[
|
||
[`last`
|
||
]
|
||
[
|
||
An iterator one past the end of the last character to replace.
|
||
]
|
||
]
|
||
[
|
||
[`sv`
|
||
]
|
||
[
|
||
The `string_view` to replace with.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`size() + (sv.size() - std::distance(first, last)) > max_size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 string::replace (3 of 5 overloads)]
|
||
|
||
Replace a range with a range.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class InputIt>
|
||
string&
|
||
replace(
|
||
const_iterator first,
|
||
const_iterator last,
|
||
InputIt first2,
|
||
InputIt last2);
|
||
```
|
||
|
||
[heading Description]
|
||
Replaces the characters in the range `{first, last)` with those of `{first2, last2)`.
|
||
|
||
[heading Precondition]
|
||
|
||
`{first, last)`is a valid range.
|
||
`{first2, last2)` is a valid range.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Remarks]
|
||
All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated.
|
||
[heading Template Parameters]
|
||
[table [[Type][Description]]
|
||
[
|
||
[`InputIt`
|
||
]
|
||
[
|
||
The type of the iterators.
|
||
]
|
||
]
|
||
]
|
||
[heading Constraints]
|
||
|
||
`InputIt`satisfies [*InputIterator].
|
||
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`first`
|
||
]
|
||
[
|
||
An iterator referring to the first character to replace.
|
||
]
|
||
]
|
||
[
|
||
[`last`
|
||
]
|
||
[
|
||
An iterator one past the end of the last character to replace.
|
||
]
|
||
]
|
||
[
|
||
[`first2`
|
||
]
|
||
[
|
||
An iterator referring to the first character to replace with.
|
||
]
|
||
]
|
||
[
|
||
[`last2`
|
||
]
|
||
[
|
||
An iterator one past the end of the last character to replace with.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`size() + (inserted - std::distance(first, last)) > max_size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 string::replace (4 of 5 overloads)]
|
||
|
||
Replace a substring with copies of a character.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
replace(
|
||
std::size_t pos,
|
||
std::size_t count,
|
||
std::size_t count2,
|
||
char ch);
|
||
```
|
||
|
||
[heading Description]
|
||
Replaces `rcount` characters starting at index `pos`with `count2` copies of `ch`, where `rcount` is `std::min(count, size() - pos)`.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Remarks]
|
||
All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated.
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index to replace at.
|
||
]
|
||
]
|
||
[
|
||
[`count`
|
||
]
|
||
[
|
||
The number of characters to replace.
|
||
]
|
||
]
|
||
[
|
||
[`count2`
|
||
]
|
||
[
|
||
The number of characters to replace with.
|
||
]
|
||
]
|
||
[
|
||
[`ch`
|
||
]
|
||
[
|
||
The character to replace with.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`size() + (count2 - rcount) > max_size()`
|
||
]
|
||
]
|
||
[
|
||
[`std::out_of_range`
|
||
]
|
||
[
|
||
`pos > size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload5 string::replace (5 of 5 overloads)]
|
||
|
||
Replace a range with copies of a character.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
replace(
|
||
const_iterator first,
|
||
const_iterator last,
|
||
std::size_t count,
|
||
char ch);
|
||
```
|
||
|
||
[heading Description]
|
||
Replaces the characters in the range `{first, last)` with `count` copies of `ch`.
|
||
|
||
[heading Precondition]
|
||
|
||
`{first, last)`is a valid range.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Remarks]
|
||
All references, pointers, or iterators referring to contained elements are invalidated. Any past-the-end iterators are also invalidated.
|
||
[heading Return Value]
|
||
`*this`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`first`
|
||
]
|
||
[
|
||
An iterator referring to the first character to replace.
|
||
]
|
||
]
|
||
[
|
||
[`last`
|
||
]
|
||
[
|
||
An iterator one past the end of the last character to replace.
|
||
]
|
||
]
|
||
[
|
||
[`count`
|
||
]
|
||
[
|
||
The number of characters to replace with.
|
||
]
|
||
]
|
||
[
|
||
[`ch`
|
||
]
|
||
[
|
||
The character to replace with.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`size() + (count - std::distance(first, last)) > max_size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:subview string::subview]
|
||
[indexterm2 subview..string]
|
||
|
||
|
||
Return a substring.
|
||
[heading Synopsis]
|
||
```
|
||
string_view
|
||
subview(
|
||
std::size_t pos = 0,
|
||
std::size_t count = ``[link json.ref.boost__json__string.npos npos]``) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns a view of a substring.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Strong guarantee.
|
||
|
||
[heading Return Value]
|
||
A `string_view` object referring to `{data() + pos, std::min(count, size() - pos))`.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index to being the substring at. The default argument for this parameter is `0`.
|
||
]
|
||
]
|
||
[
|
||
[`count`
|
||
]
|
||
[
|
||
The length of the substring. The default argument for this parameter is [link json.ref.boost__json__string.npos `npos`].
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::out_of_range`
|
||
]
|
||
[
|
||
`pos > size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:copy string::copy]
|
||
[indexterm2 copy..string]
|
||
|
||
|
||
Copy a substring to another string.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
copy(
|
||
char* dest,
|
||
std::size_t count,
|
||
std::size_t pos = 0) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Copies `std::min(count, size() - pos)` characters starting at index `pos` to the string pointed to by `dest`.
|
||
|
||
[heading Remarks]
|
||
The resulting string is not null terminated.
|
||
[heading Return Value]
|
||
The number of characters copied.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`count`
|
||
]
|
||
[
|
||
The number of characters to copy.
|
||
]
|
||
]
|
||
[
|
||
[`dest`
|
||
]
|
||
[
|
||
The string to copy to.
|
||
]
|
||
]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index to begin copying from. The default argument for this parameter is `0`.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::out_of_range`
|
||
]
|
||
[
|
||
`pos > max_size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:resize string::resize]
|
||
[indexterm2 resize..string]
|
||
|
||
|
||
Change the size of the string.
|
||
```
|
||
void
|
||
``[link json.ref.boost__json__string.resize.overload1 resize]``(
|
||
std::size_t count);
|
||
``[''''»''' [link json.ref.boost__json__string.resize.overload1 `more...`]]``
|
||
|
||
void
|
||
``[link json.ref.boost__json__string.resize.overload2 resize]``(
|
||
std::size_t count,
|
||
char ch);
|
||
``[''''»''' [link json.ref.boost__json__string.resize.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::resize (1 of 2 overloads)]
|
||
|
||
Change the size of the string.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
resize(
|
||
std::size_t count);
|
||
```
|
||
|
||
[heading Description]
|
||
Resizes the string to contain `count` characters. If `count > size()`, characters with the value `0` are appended. Otherwise, `size()` is reduced to `count`.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`count`
|
||
]
|
||
[
|
||
The size to resize the string to.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::out_of_range`
|
||
]
|
||
[
|
||
`count > max_size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::resize (2 of 2 overloads)]
|
||
|
||
Change the size of the string.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
resize(
|
||
std::size_t count,
|
||
char ch);
|
||
```
|
||
|
||
[heading Description]
|
||
Resizes the string to contain `count` characters. If `count > size()`, copies of `ch` are appended. Otherwise, `size()` is reduced to `count`.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`count`
|
||
]
|
||
[
|
||
The size to resize the string to.
|
||
]
|
||
]
|
||
[
|
||
[`ch`
|
||
]
|
||
[
|
||
The characters to append if the size increases.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::out_of_range`
|
||
]
|
||
[
|
||
`count > max_size()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:grow string::grow]
|
||
[indexterm2 grow..string]
|
||
|
||
|
||
Increase size without changing capacity.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
grow(
|
||
std::size_t n);
|
||
```
|
||
|
||
[heading Description]
|
||
This increases the size of the string by `n` characters, adjusting the position of the terminating null for the new size. The new characters remain uninitialized. This function may be used to append characters directly into the storage between `end()` and `data() + capacity()`.
|
||
|
||
[heading Precondition]
|
||
|
||
```
|
||
count <= capacity() - size()
|
||
```
|
||
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`n`
|
||
]
|
||
[
|
||
The amount to increase the size by.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:find string::find]
|
||
[indexterm2 find..string]
|
||
|
||
|
||
Find the first occurrence of a string within the string.
|
||
```
|
||
std::size_t
|
||
``[link json.ref.boost__json__string.find.overload1 find]``(
|
||
string_view sv,
|
||
std::size_t pos = 0) const;
|
||
``[''''»''' [link json.ref.boost__json__string.find.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Find the first occurrence of a character within the string.
|
||
```
|
||
std::size_t
|
||
``[link json.ref.boost__json__string.find.overload2 find]``(
|
||
char ch,
|
||
std::size_t pos = 0) const;
|
||
``[''''»''' [link json.ref.boost__json__string.find.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::find (1 of 2 overloads)]
|
||
|
||
Find the first occurrence of a string within the string.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
find(
|
||
string_view sv,
|
||
std::size_t pos = 0) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns the lowest index `idx` greater than or equal to `pos` where each element of `sv` is equal to that of `{begin() + idx, begin() + idx + sv.size())` if one exists, and [link json.ref.boost__json__string.npos `npos`] otherwise.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear.
|
||
|
||
[heading Return Value]
|
||
The first occurrence of `sv` within the string starting at the index `pos`, or [link json.ref.boost__json__string.npos `npos`] if none exists.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sv`
|
||
]
|
||
[
|
||
The `string_view` to search for.
|
||
]
|
||
]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index to start searching at. The default argument for this parameter is `0`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::find (2 of 2 overloads)]
|
||
|
||
Find the first occurrence of a character within the string.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
find(
|
||
char ch,
|
||
std::size_t pos = 0) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns the index corrosponding to the first occurrence of `ch` within `{begin() + pos, end())` if it exists, and [link json.ref.boost__json__string.npos `npos`] otherwise.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear.
|
||
|
||
[heading Return Value]
|
||
The first occurrence of `ch` within the string starting at the index `pos`, or [link json.ref.boost__json__string.npos `npos`] if none exists.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`ch`
|
||
]
|
||
[
|
||
The character to search for.
|
||
]
|
||
]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index to start searching at. The default argument for this parameter is `0`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:rfind string::rfind]
|
||
[indexterm2 rfind..string]
|
||
|
||
|
||
Find the last occurrence of a string within the string.
|
||
```
|
||
std::size_t
|
||
``[link json.ref.boost__json__string.rfind.overload1 rfind]``(
|
||
string_view sv,
|
||
std::size_t pos = ``[link json.ref.boost__json__string.npos npos]``) const;
|
||
``[''''»''' [link json.ref.boost__json__string.rfind.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Find the last occurrence of a character within the string.
|
||
```
|
||
std::size_t
|
||
``[link json.ref.boost__json__string.rfind.overload2 rfind]``(
|
||
char ch,
|
||
std::size_t pos = ``[link json.ref.boost__json__string.npos npos]``) const;
|
||
``[''''»''' [link json.ref.boost__json__string.rfind.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::rfind (1 of 2 overloads)]
|
||
|
||
Find the last occurrence of a string within the string.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
rfind(
|
||
string_view sv,
|
||
std::size_t pos = ``[link json.ref.boost__json__string.npos npos]``) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns the highest index `idx` less than or equal to `pos` where each element of `sv` is equal to that of `{begin() + idx, begin() + idx + sv.size())` if one exists, and [link json.ref.boost__json__string.npos `npos`] otherwise.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear.
|
||
|
||
[heading Return Value]
|
||
The last occurrence of `sv` within the string starting before or at the index `pos`, or [link json.ref.boost__json__string.npos `npos`] if none exists.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sv`
|
||
]
|
||
[
|
||
The `string_view` to search for.
|
||
]
|
||
]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index to start searching at. The default argument for this parameter is [link json.ref.boost__json__string.npos `npos`].
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::rfind (2 of 2 overloads)]
|
||
|
||
Find the last occurrence of a character within the string.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
rfind(
|
||
char ch,
|
||
std::size_t pos = ``[link json.ref.boost__json__string.npos npos]``) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns index corrosponding to the last occurrence of `ch` within `{begin(), begin() + pos}` if it exists, and [link json.ref.boost__json__string.npos `npos`] otherwise.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear.
|
||
|
||
[heading Return Value]
|
||
The last occurrence of `ch` within the string starting before or at the index `pos`, or [link json.ref.boost__json__string.npos `npos`] if none exists.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`ch`
|
||
]
|
||
[
|
||
The character to search for.
|
||
]
|
||
]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index to stop searching at. The default argument for this parameter is [link json.ref.boost__json__string.npos `npos`].
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:find_first_of string::find_first_of]
|
||
[indexterm2 find_first_of..string]
|
||
|
||
|
||
Find the first occurrence of any of the characters within the string.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
find_first_of(
|
||
string_view sv,
|
||
std::size_t pos = 0) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns the index corrosponding to the first occurrence of any of the characters of `sv` within `{begin() + pos, end())` if it exists, and [link json.ref.boost__json__string.npos `npos`] otherwise.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear.
|
||
|
||
[heading Return Value]
|
||
The first occurrence of any of the characters within `sv` within the string starting at the index `pos`, or [link json.ref.boost__json__string.npos `npos`] if none exists.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sv`
|
||
]
|
||
[
|
||
The characters to search for.
|
||
]
|
||
]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index to start searching at. The default argument for this parameter is `0`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:find_first_not_of string::find_first_not_of]
|
||
[indexterm2 find_first_not_of..string]
|
||
|
||
|
||
Find the first occurrence of any of the characters not within the string.
|
||
```
|
||
std::size_t
|
||
``[link json.ref.boost__json__string.find_first_not_of.overload1 find_first_not_of]``(
|
||
string_view sv,
|
||
std::size_t pos = 0) const;
|
||
``[''''»''' [link json.ref.boost__json__string.find_first_not_of.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Find the first occurrence of a character not equal to `ch`.
|
||
```
|
||
std::size_t
|
||
``[link json.ref.boost__json__string.find_first_not_of.overload2 find_first_not_of]``(
|
||
char ch,
|
||
std::size_t pos = 0) const;
|
||
``[''''»''' [link json.ref.boost__json__string.find_first_not_of.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::find_first_not_of (1 of 2 overloads)]
|
||
|
||
Find the first occurrence of any of the characters not within the string.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
find_first_not_of(
|
||
string_view sv,
|
||
std::size_t pos = 0) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns the index corrosponding to the first character of `{begin() + pos, end())` that is not within `sv` if it exists, and [link json.ref.boost__json__string.npos `npos`] otherwise.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear.
|
||
|
||
[heading Return Value]
|
||
The first occurrence of a character that is not within `sv` within the string starting at the index `pos`, or [link json.ref.boost__json__string.npos `npos`] if none exists.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sv`
|
||
]
|
||
[
|
||
The characters to ignore.
|
||
]
|
||
]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index to start searching at. The default argument for this parameter is `0`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::find_first_not_of (2 of 2 overloads)]
|
||
|
||
Find the first occurrence of a character not equal to `ch`.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
find_first_not_of(
|
||
char ch,
|
||
std::size_t pos = 0) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns the index corrosponding to the first character of `{begin() + pos, end())` that is not equal to `ch` if it exists, and [link json.ref.boost__json__string.npos `npos`] otherwise.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear.
|
||
|
||
[heading Return Value]
|
||
The first occurrence of a character that is not equal to `ch`, or [link json.ref.boost__json__string.npos `npos`] if none exists.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`ch`
|
||
]
|
||
[
|
||
The character to ignore.
|
||
]
|
||
]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index to start searching at. The default argument for this parameter is `0`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:find_last_of string::find_last_of]
|
||
[indexterm2 find_last_of..string]
|
||
|
||
|
||
Find the last occurrence of any of the characters within the string.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
find_last_of(
|
||
string_view sv,
|
||
std::size_t pos = ``[link json.ref.boost__json__string.npos npos]``) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns the index corrosponding to the last occurrence of any of the characters of `sv` within `{begin(), begin() + pos}` if it exists, and [link json.ref.boost__json__string.npos `npos`] otherwise.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear.
|
||
|
||
[heading Return Value]
|
||
The last occurrence of any of the characters within `sv` within the string starting before or at the index `pos`, or [link json.ref.boost__json__string.npos `npos`] if none exists.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sv`
|
||
]
|
||
[
|
||
The characters to search for.
|
||
]
|
||
]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index to stop searching at. The default argument for this parameter is [link json.ref.boost__json__string.npos `npos`].
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:find_last_not_of string::find_last_not_of]
|
||
[indexterm2 find_last_not_of..string]
|
||
|
||
|
||
Find the last occurrence of a character not within the string.
|
||
```
|
||
std::size_t
|
||
``[link json.ref.boost__json__string.find_last_not_of.overload1 find_last_not_of]``(
|
||
string_view sv,
|
||
std::size_t pos = ``[link json.ref.boost__json__string.npos npos]``) const;
|
||
``[''''»''' [link json.ref.boost__json__string.find_last_not_of.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Find the last occurrence of a character not equal to `ch`.
|
||
```
|
||
std::size_t
|
||
``[link json.ref.boost__json__string.find_last_not_of.overload2 find_last_not_of]``(
|
||
char ch,
|
||
std::size_t pos = ``[link json.ref.boost__json__string.npos npos]``) const;
|
||
``[''''»''' [link json.ref.boost__json__string.find_last_not_of.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 string::find_last_not_of (1 of 2 overloads)]
|
||
|
||
Find the last occurrence of a character not within the string.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
find_last_not_of(
|
||
string_view sv,
|
||
std::size_t pos = ``[link json.ref.boost__json__string.npos npos]``) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns the index corrosponding to the last character of `{begin(), begin() + pos}` that is not within `sv` if it exists, and [link json.ref.boost__json__string.npos `npos`] otherwise.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear.
|
||
|
||
[heading Return Value]
|
||
The last occurrence of a character that is not within `sv` within the string before or at the index `pos`, or [link json.ref.boost__json__string.npos `npos`] if none exists.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sv`
|
||
]
|
||
[
|
||
The characters to ignore.
|
||
]
|
||
]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index to stop searching at. The default argument for this parameter is [link json.ref.boost__json__string.npos `npos`].
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 string::find_last_not_of (2 of 2 overloads)]
|
||
|
||
Find the last occurrence of a character not equal to `ch`.
|
||
[heading Synopsis]
|
||
```
|
||
std::size_t
|
||
find_last_not_of(
|
||
char ch,
|
||
std::size_t pos = ``[link json.ref.boost__json__string.npos npos]``) const;
|
||
```
|
||
|
||
[heading Description]
|
||
Returns the index corrosponding to the last character of `{begin(), begin() + pos}` that is not equal to `ch` if it exists, and [link json.ref.boost__json__string.npos `npos`] otherwise.
|
||
|
||
[heading Complexity]
|
||
|
||
Linear.
|
||
|
||
[heading Return Value]
|
||
The last occurrence of a character that is not equal to `ch` before or at the index `pos`, or [link json.ref.boost__json__string.npos `npos`] if none exists.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`ch`
|
||
]
|
||
[
|
||
The character to ignore.
|
||
]
|
||
]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
The index to start searching at. The default argument for this parameter is [link json.ref.boost__json__string.npos `npos`].
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:max_size string::max_size]
|
||
[indexterm2 max_size..string]
|
||
|
||
|
||
Return the maximum number of characters any string can hold.
|
||
[heading Synopsis]
|
||
```
|
||
static
|
||
constexpr std::size_t
|
||
max_size();
|
||
```
|
||
|
||
[heading Description]
|
||
The maximum is an implementation-defined number. This value is a theoretical limit; at runtime, the actual maximum size may be less due to resource limits.
|
||
|
||
[heading Complexity]
|
||
|
||
Constant.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__string_kind_t string_kind_t]
|
||
|
||
A tag type used to select a [link json.ref.boost__json__value `value`] constructor overload.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/kind.hpp]
|
||
|
||
```
|
||
struct string_kind_t
|
||
```
|
||
|
||
[heading Description]
|
||
The library provides the constant [link json.ref.boost__json__string_kind `string_kind`] which may be used to select the [link json.ref.boost__json__value `value`] constructor that creates an empty [link json.ref.boost__json__string `string`].
|
||
|
||
[heading See Also]
|
||
[link json.ref.boost__json__string_kind `string_kind`]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__value value]
|
||
|
||
The type used to represent any JSON value.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/value.hpp]
|
||
|
||
```
|
||
class value
|
||
```
|
||
|
||
[heading Types]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__value.allocator_type allocator_type]]
|
||
]
|
||
[The type of ['Allocator] returned by [link json.ref.boost__json__value.get_allocator `get_allocator`].
|
||
]
|
||
]
|
||
]
|
||
[heading Member Functions]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_array as_array]]
|
||
]
|
||
[Return a reference to the underlying [link json.ref.boost__json__array `array`], or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_bool as_bool]]
|
||
]
|
||
[Return a reference to the underlying `bool`, or throw an exception. [br][role silver —][br]Return the underlying `bool`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_double as_double]]
|
||
]
|
||
[Return a reference to the underlying `double`, or throw an exception. [br][role silver —][br]Return the underlying `double`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_int64 as_int64]]
|
||
]
|
||
[Return a reference to the underlying `std::int64_t`, or throw an exception. [br][role silver —][br]Return the underlying `std::int64_t`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_object as_object]]
|
||
]
|
||
[Return a reference to the underlying `object`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_string as_string]]
|
||
]
|
||
[Return a reference to the underlying `string`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.as_uint64 as_uint64]]
|
||
]
|
||
[Return a reference to the underlying `std::uint64_t`, or throw an exception. [br][role silver —][br]Return the underlying `std::uint64_t`, or throw an exception.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.at at]]
|
||
]
|
||
[Access an element, with bounds checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_array emplace_array]]
|
||
]
|
||
[Return a reference to an [link json.ref.boost__json__array `array`], changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_bool emplace_bool]]
|
||
]
|
||
[Return a reference to a `bool`, changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_double emplace_double]]
|
||
]
|
||
[Return a reference to a `double`, changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_int64 emplace_int64]]
|
||
]
|
||
[Return a reference to a `std::int64_t`, changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_null emplace_null]]
|
||
]
|
||
[Change the kind to null, discarding the previous contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_object emplace_object]]
|
||
]
|
||
[Return a reference to an [link json.ref.boost__json__object `object`], changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_string emplace_string]]
|
||
]
|
||
[Return a reference to a [link json.ref.boost__json__string `string`], changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.emplace_uint64 emplace_uint64]]
|
||
]
|
||
[Return a reference to a `std::uint64_t`, changing the kind and replacing the contents.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_allocator get_allocator]]
|
||
]
|
||
[Return the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_array get_array]]
|
||
]
|
||
[Return a reference to the underlying `array`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_bool get_bool]]
|
||
]
|
||
[Return a reference to the underlying `bool`, without checking. [br][role silver —][br]Return the underlying `bool`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_double get_double]]
|
||
]
|
||
[Return a reference to the underlying `double`, without checking. [br][role silver —][br]Return the underlying `double`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_int64 get_int64]]
|
||
]
|
||
[Return a reference to the underlying `std::int64_t`, without checking. [br][role silver —][br]Return the underlying `std::int64_t`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_object get_object]]
|
||
]
|
||
[Return a reference to the underlying `object`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_string get_string]]
|
||
]
|
||
[Return a reference to the underlying `string`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.get_uint64 get_uint64]]
|
||
]
|
||
[Return a reference to the underlying `std::uint64_t`, without checking. [br][role silver —][br]Return the underlying `std::uint64_t`, without checking.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_array if_array]]
|
||
]
|
||
[Return an [link json.ref.boost__json__array `array`] pointer if this is an array, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_bool if_bool]]
|
||
]
|
||
[Return a `bool` pointer if this is a boolean, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_double if_double]]
|
||
]
|
||
[Return a `double` pointer if this is a double, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_int64 if_int64]]
|
||
]
|
||
[Return an `int64_t` pointer if this is a signed integer, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_object if_object]]
|
||
]
|
||
[Return an [link json.ref.boost__json__object `object`] pointer if this is an object, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_string if_string]]
|
||
]
|
||
[Return a [link json.ref.boost__json__string `string`] pointer if this is a string, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.if_uint64 if_uint64]]
|
||
]
|
||
[Return a `uint64_t` pointer if this is an unsigned integer, else return `nullptr`
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_array is_array]]
|
||
]
|
||
[Return `true` if this is an array.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_bool is_bool]]
|
||
]
|
||
[Return `true` if this is a bool.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_double is_double]]
|
||
]
|
||
[Return `true` if this is a double.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_int64 is_int64]]
|
||
]
|
||
[Return `true` if this is a signed integer.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_null is_null]]
|
||
]
|
||
[Returns true if this is a null.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_number is_number]]
|
||
]
|
||
[Returns true if this is a number.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_object is_object]]
|
||
]
|
||
[Return `true` if this is an object.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_primitive is_primitive]]
|
||
]
|
||
[Returns true if this is not an array or object.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_string is_string]]
|
||
]
|
||
[Return `true` if this is a string.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_structured is_structured]]
|
||
]
|
||
[Returns true if this is an array or object.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.is_uint64 is_uint64]]
|
||
]
|
||
[Return `true` if this is a unsigned integer.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.kind kind]]
|
||
]
|
||
[Returns the kind of this JSON value.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.operator_eq_ operator=]]
|
||
]
|
||
[Assignment. [br][role silver —][br]Copy assignment. [br][role silver —][br]Move assignment.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.storage storage]]
|
||
]
|
||
[Return the memory resource associated with the value.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.swap swap]]
|
||
]
|
||
[Swap the given values.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.to_number to_number]]
|
||
]
|
||
[Return the stored number cast to an arithmetic type.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.value value] [role silver \[constructor\]]]
|
||
]
|
||
[Default constructor. [br][role silver —][br]Constructor. [br][role silver —][br]Pilfer constructor. [br][role silver —][br]Copy constructor. [br][role silver —][br]Move constructor. [br][role silver —][br]Construct a null. [br][role silver —][br]Construct a bool. [br][role silver —][br]Construct a `std::int64_t`. [br][role silver —][br]Construct a `std::uint64_t`. [br][role silver —][br]Construct a `double`. [br][role silver —][br]Construct a [link json.ref.boost__json__string `string`]. [br][role silver —][br]Construct an [link json.ref.boost__json__array `array`]. [br][role silver —][br]Construct an [link json.ref.boost__json__object `object`]. [br][role silver —][br]Construct from an initializer-list.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value._value ~value] [role silver \[destructor\]]]
|
||
]
|
||
[Destructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Friends]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__value.operator_not__eq_ operator!=]]
|
||
]
|
||
[Return `true` if two values are not equal.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.operator_eq__eq_ operator==]]
|
||
]
|
||
[Return `true` if two values are equal.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value.swap swap]]
|
||
]
|
||
[Swap the given values.
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
This is a [@https://en.cppreference.com/w/cpp/concepts/regular ['Regular]]. ['Regular] type which works like a variant of the basic JSON data types: array, object, string, number, boolean, and null.
|
||
|
||
[heading Thread Safety]
|
||
|
||
Distinct instances may be accessed concurrently. Non-const member functions of a shared instance may not be called concurrently with any other member functions of that instance.
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
[section:operator_eq_ value::operator=]
|
||
[indexterm2 operator=..value]
|
||
|
||
|
||
Assignment.
|
||
```
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload1 operator=]``(
|
||
signed char i);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload1 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload2 operator=]``(
|
||
short i);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload2 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload3 operator=]``(
|
||
int i);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload3 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload4 operator=]``(
|
||
long i);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload4 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload5 operator=]``(
|
||
long long i);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload5 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload6 operator=]``(
|
||
unsigned char u);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload6 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload7 operator=]``(
|
||
unsigned short u);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload7 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload8 operator=]``(
|
||
unsigned int u);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload8 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload9 operator=]``(
|
||
unsigned long u);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload9 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload10 operator=]``(
|
||
unsigned long long u);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload10 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload11 operator=]``(
|
||
string_view s);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload11 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload12 operator=]``(
|
||
char const* s);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload12 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload13 operator=]``(
|
||
string const& s);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload13 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload16 operator=]``(
|
||
std::initializer_list< value_ref > init);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload16 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload17 operator=]``(
|
||
std::nullptr_t);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload17 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload18 operator=]``(
|
||
bool b);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload18 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload19 operator=]``(
|
||
double d);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload19 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload20 operator=]``(
|
||
string&& s);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload20 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload21 operator=]``(
|
||
array const& arr);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload21 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload22 operator=]``(
|
||
array&& arr);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload22 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload23 operator=]``(
|
||
object const& obj);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload23 `more...`]]``
|
||
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload24 operator=]``(
|
||
object&& obj);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload24 `more...`]]``
|
||
```
|
||
|
||
|
||
Copy assignment.
|
||
```
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload14 operator=]``(
|
||
value const& other);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload14 `more...`]]``
|
||
```
|
||
|
||
|
||
Move assignment.
|
||
```
|
||
value&
|
||
``[link json.ref.boost__json__value.operator_eq_.overload15 operator=]``(
|
||
value&& other);
|
||
``[''''»''' [link json.ref.boost__json__value.operator_eq_.overload15 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::operator= (1 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
signed char i);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace `*this` with `i`.
|
||
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`i`
|
||
]
|
||
[
|
||
The new value.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::operator= (2 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
short i);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace `*this` with `i`.
|
||
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`i`
|
||
]
|
||
[
|
||
The new value.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 value::operator= (3 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
int i);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace `*this` with `i`.
|
||
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`i`
|
||
]
|
||
[
|
||
The new value.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 value::operator= (4 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
long i);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace `*this` with `i`.
|
||
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`i`
|
||
]
|
||
[
|
||
The new value.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload5 value::operator= (5 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
long long i);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace `*this` with `i`.
|
||
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`i`
|
||
]
|
||
[
|
||
The new value.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload6 value::operator= (6 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
unsigned char u);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace `*this` with `i`.
|
||
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`u`
|
||
]
|
||
[
|
||
The new value.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload7 value::operator= (7 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
unsigned short u);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace `*this` with `i`.
|
||
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`u`
|
||
]
|
||
[
|
||
The new value.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload8 value::operator= (8 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
unsigned int u);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace `*this` with `i`.
|
||
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`u`
|
||
]
|
||
[
|
||
The new value.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload9 value::operator= (9 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
unsigned long u);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace `*this` with `i`.
|
||
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`u`
|
||
]
|
||
[
|
||
The new value.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload10 value::operator= (10 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
unsigned long long u);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace `*this` with `i`.
|
||
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`u`
|
||
]
|
||
[
|
||
The new value.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload11 value::operator= (11 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
string_view s);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace `*this` with a copy of the string `s`.
|
||
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Complexity]
|
||
Linear in the sum of sizes of `*this` and `s`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The new string.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload12 value::operator= (12 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
char const* s);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace `*this` with a copy of the string `s`.
|
||
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Complexity]
|
||
Linear in the sum of sizes of `*this` and `s`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The new string.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload13 value::operator= (13 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
string const& s);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace `*this` with a copy of the string `s`.
|
||
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Complexity]
|
||
Linear in the sum of sizes of `*this` and `s`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The new string.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload14 value::operator= (14 of 24 overloads)]
|
||
|
||
Copy assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
value const& other);
|
||
```
|
||
|
||
[heading Description]
|
||
The contents of the value are replaced with an element-wise copy of the contents of `other`.
|
||
|
||
[heading Complexity]
|
||
Linear in the size of `*this` plus `other`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The value to copy.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload15 value::operator= (15 of 24 overloads)]
|
||
|
||
Move assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
value&& other);
|
||
```
|
||
|
||
[heading Description]
|
||
The contents of the value are replaced with the contents of `other` using move semantics:
|
||
|
||
* If `*other.storage() == *sp`, ownership of the underlying memory is transferred in constant time, with no possibility of exceptions. After assignment, the moved-from value becomes a null with its current storage pointer.
|
||
|
||
* If `*other.storage() != *sp`, an element-wise copy is performed if `other.is_structured() == true`, which may throw. In this case, the moved-from value is not changed.
|
||
|
||
[heading Complexity]
|
||
Constant, or linear in `this->size()` plus `other.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The value to assign from.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload16 value::operator= (16 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
std::initializer_list< value_ref > init);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace `*this` with the value formed by constructing from `init` and `this->storage()`. If the initializer list consists of key/value pairs, the resulting [link json.ref.boost__json__object `object`] is assigned. Otherwise an [link json.ref.boost__json__array `array`] is assigned. The contents of the initializer list are moved to `*this` using the existing memory resource.
|
||
|
||
[heading Complexity]
|
||
Linear in `init.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`init`
|
||
]
|
||
[
|
||
The initializer list to assign from.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload17 value::operator= (17 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
std::nullptr_t);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace `*this` with null.
|
||
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
|
||
[endsect]
|
||
|
||
[section:overload18 value::operator= (18 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
bool b);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace `*this` with `b`.
|
||
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`b`
|
||
]
|
||
[
|
||
The new value.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload19 value::operator= (19 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
double d);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace `*this` with `d`.
|
||
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`d`
|
||
]
|
||
[
|
||
The new value.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload20 value::operator= (20 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
string&& s);
|
||
```
|
||
|
||
[heading Description]
|
||
The contents of the value are replaced with the contents of `s` using move semantics:
|
||
|
||
* If `*other.storage() == *this->storage()`, ownership of the underlying memory is transferred in constant time, with no possibility of exceptions. After assignment, the moved-from string becomes empty with its current storage pointer.
|
||
|
||
* If `*other.storage() != *this->storage()`, an element-wise copy is performed, which may throw. In this case, the moved-from string is not changed.
|
||
|
||
[heading Complexity]
|
||
Constant, or linear in the size of `*this` plus `s.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The string to move-assign from.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload21 value::operator= (21 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
array const& arr);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace `*this` with a copy of the array `arr`.
|
||
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Complexity]
|
||
Linear in the sum of sizes of `*this` and `arr`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`arr`
|
||
]
|
||
[
|
||
The new array.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload22 value::operator= (22 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
array&& arr);
|
||
```
|
||
|
||
[heading Description]
|
||
The contents of the value are replaced with the contents of `arr` using move semantics:
|
||
|
||
* If `*arr.storage() == *this->storage()`, ownership of the underlying memory is transferred in constant time, with no possibility of exceptions. After assignment, the moved-from array becomes empty with its current storage pointer.
|
||
|
||
* If `*arr.storage() != *this->storage()`, an element-wise copy is performed, which may throw. In this case, the moved-from array is not changed.
|
||
|
||
[heading Complexity]
|
||
Constant, or linear in the size of `*this` plus `arr.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`arr`
|
||
]
|
||
[
|
||
The array to move-assign from.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload23 value::operator= (23 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
object const& obj);
|
||
```
|
||
|
||
[heading Description]
|
||
Replace `*this` with a copy of the obect `obj`.
|
||
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Complexity]
|
||
Linear in the sum of sizes of `*this` and `obj`
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`obj`
|
||
]
|
||
[
|
||
The new object.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload24 value::operator= (24 of 24 overloads)]
|
||
|
||
Assignment.
|
||
[heading Synopsis]
|
||
```
|
||
value&
|
||
operator=(
|
||
object&& obj);
|
||
```
|
||
|
||
[heading Description]
|
||
The contents of the value are replaced with the contents of `obj` using move semantics:
|
||
|
||
* If `*obj.storage() == *this->storage()`, ownership of the underlying memory is transferred in constant time, with no possibility of exceptions. After assignment, the moved-from object becomes empty with its current storage pointer.
|
||
|
||
* If `*obj.storage() != *this->storage()`, an element-wise copy is performed, which may throw. In this case, the moved-from object is not changed.
|
||
|
||
[heading Complexity]
|
||
Constant, or linear in the size of `*this` plus `obj.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`obj`
|
||
]
|
||
[
|
||
The object to move-assign from.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:allocator_type value::allocator_type]
|
||
[indexterm2 allocator_type..value]
|
||
|
||
|
||
The type of ['Allocator] returned by [link json.ref.boost__json__value.get_allocator `get_allocator`].
|
||
[heading Synopsis]
|
||
```
|
||
using allocator_type = ``['see-below]``;
|
||
```
|
||
|
||
[heading Description]
|
||
This type is a [link json.ref.boost__json__polymorphic_allocator `polymorphic_allocator`].
|
||
|
||
[endsect]
|
||
|
||
[section:_value value::~value]
|
||
[indexterm2 ~value..value]
|
||
|
||
|
||
Destructor.
|
||
[heading Synopsis]
|
||
```
|
||
~value();
|
||
```
|
||
|
||
[heading Description]
|
||
The value and all of its contents are destroyed. Any dynamically allocated memory that was allocated internally is freed.
|
||
|
||
[heading Complexity]
|
||
Constant, or linear in size for array or object.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:value value::value]
|
||
[indexterm2 value..value]
|
||
|
||
|
||
Default constructor.
|
||
```
|
||
``[link json.ref.boost__json__value.value.overload1 value]``();
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Constructor.
|
||
```
|
||
explicit
|
||
``[link json.ref.boost__json__value.value.overload2 value]``(
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload2 `more...`]]``
|
||
```
|
||
|
||
|
||
Pilfer constructor.
|
||
```
|
||
``[link json.ref.boost__json__value.value.overload3 value]``(
|
||
pilfered< value > other);
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload3 `more...`]]``
|
||
```
|
||
|
||
|
||
Copy constructor.
|
||
```
|
||
``[link json.ref.boost__json__value.value.overload4 value]``(
|
||
value const& other);
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload4 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload5 value]``(
|
||
value const& other,
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload5 `more...`]]``
|
||
```
|
||
|
||
|
||
Move constructor.
|
||
```
|
||
``[link json.ref.boost__json__value.value.overload6 value]``(
|
||
value&& other);
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload6 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload7 value]``(
|
||
value&& other,
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload7 `more...`]]``
|
||
```
|
||
|
||
|
||
Construct a null.
|
||
```
|
||
``[link json.ref.boost__json__value.value.overload8 value]``(
|
||
std::nullptr_t,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload8 `more...`]]``
|
||
```
|
||
|
||
|
||
Construct a bool.
|
||
```
|
||
``[link json.ref.boost__json__value.value.overload9 value]``(
|
||
bool b,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload9 `more...`]]``
|
||
```
|
||
|
||
|
||
Construct a `std::int64_t`.
|
||
```
|
||
``[link json.ref.boost__json__value.value.overload10 value]``(
|
||
signed char i,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload10 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload11 value]``(
|
||
short i,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload11 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload12 value]``(
|
||
int i,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload12 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload13 value]``(
|
||
long i,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload13 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload14 value]``(
|
||
long long i,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload14 `more...`]]``
|
||
```
|
||
|
||
|
||
Construct a `std::uint64_t`.
|
||
```
|
||
``[link json.ref.boost__json__value.value.overload15 value]``(
|
||
unsigned char u,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload15 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload16 value]``(
|
||
unsigned short u,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload16 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload17 value]``(
|
||
unsigned int u,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload17 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload18 value]``(
|
||
unsigned long u,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload18 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload19 value]``(
|
||
unsigned long long u,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload19 `more...`]]``
|
||
```
|
||
|
||
|
||
Construct a `double`.
|
||
```
|
||
``[link json.ref.boost__json__value.value.overload20 value]``(
|
||
double d,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload20 `more...`]]``
|
||
```
|
||
|
||
|
||
Construct a [link json.ref.boost__json__string `string`].
|
||
```
|
||
``[link json.ref.boost__json__value.value.overload21 value]``(
|
||
string_view s,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload21 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload22 value]``(
|
||
char const* s,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload22 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload23 value]``(
|
||
string other);
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload23 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload24 value]``(
|
||
string const& other,
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload24 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload25 value]``(
|
||
string&& other,
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload25 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload26 value]``(
|
||
string_kind_t,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload26 `more...`]]``
|
||
```
|
||
|
||
|
||
Construct an [link json.ref.boost__json__array `array`].
|
||
```
|
||
``[link json.ref.boost__json__value.value.overload27 value]``(
|
||
array other);
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload27 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload28 value]``(
|
||
array const& other,
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload28 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload29 value]``(
|
||
array&& other,
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload29 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload30 value]``(
|
||
array_kind_t,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload30 `more...`]]``
|
||
```
|
||
|
||
|
||
Construct an [link json.ref.boost__json__object `object`].
|
||
```
|
||
``[link json.ref.boost__json__value.value.overload31 value]``(
|
||
object other);
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload31 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload32 value]``(
|
||
object const& other,
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload32 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload33 value]``(
|
||
object&& other,
|
||
storage_ptr sp);
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload33 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value.value.overload34 value]``(
|
||
object_kind_t,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload34 `more...`]]``
|
||
```
|
||
|
||
|
||
Construct from an initializer-list.
|
||
```
|
||
``[link json.ref.boost__json__value.value.overload35 value]``(
|
||
std::initializer_list< value_ref > init,
|
||
storage_ptr sp = {});
|
||
``[''''»''' [link json.ref.boost__json__value.value.overload35 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::value (1 of 35 overloads)]
|
||
|
||
Default constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value();
|
||
```
|
||
|
||
[heading Description]
|
||
The constructed value is null, using the default memory resource.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::value (2 of 35 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
The constructed value is null, using the specified [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 value::value (3 of 35 overloads)]
|
||
|
||
Pilfer constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
pilfered< value > other);
|
||
```
|
||
|
||
[heading Description]
|
||
The value is constructed by acquiring ownership of the contents of `other` using pilfer semantics. This is more efficient than move construction, when it is known that the moved-from object will be immediately destroyed afterwards.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The value to pilfer. After pilfer construction, `other` is not in a usable state and may only be destroyed.
|
||
]
|
||
]
|
||
]
|
||
[heading See Also]
|
||
[link json.ref.boost__json__pilfer `pilfer`], [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0308r0.html Valueless Variants Considered Harmful]
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 value::value (4 of 35 overloads)]
|
||
|
||
Copy constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
value const& other);
|
||
```
|
||
|
||
[heading Description]
|
||
The value is constructed with a copy of the contents of `other`, using the same memory resource as `other`.
|
||
|
||
[heading Complexity]
|
||
Linear in the size of `other`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The value to copy.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload5 value::value (5 of 35 overloads)]
|
||
|
||
Copy constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
value const& other,
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
The value is constructed with a copy of the contents of `other`, using the specified memory resource.
|
||
|
||
[heading Complexity]
|
||
Linear in the size of `other`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The value to copy.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload6 value::value (6 of 35 overloads)]
|
||
|
||
Move constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
value&& other);
|
||
```
|
||
|
||
[heading Description]
|
||
The value is constructed by acquiring ownership of the contents of `other` and shared ownership of `other`'s memory resource.
|
||
|
||
[heading Remarks]
|
||
|
||
After construction, the moved-from value becomes a null value with its current storage pointer.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The value to move.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload7 value::value (7 of 35 overloads)]
|
||
|
||
Move constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
value&& other,
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
The value is constructed with the contents of `other` by move semantics, using the specified memory resource:
|
||
|
||
* If `*other.storage() == *sp`, ownership of the underlying memory is transferred in constant time, with no possibility of exceptions. After construction, the moved-from value becomes a null value with its current storage pointer.
|
||
|
||
* If `*other.storage() != *sp`, an element-wise copy is performed if `other.is_structured() == true`, which may throw. In this case, the moved-from value is not changed.
|
||
|
||
[heading Complexity]
|
||
Constant or linear in the size of `other`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The value to move.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload8 value::value (8 of 35 overloads)]
|
||
|
||
Construct a null.
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
std::nullptr_t,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
A null value is a monostate.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload9 value::value (9 of 35 overloads)]
|
||
|
||
Construct a bool.
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
bool b,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
This constructs a `bool` value using the specified memory resource.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`b`
|
||
]
|
||
[
|
||
The initial value.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload10 value::value (10 of 35 overloads)]
|
||
|
||
Construct a `std::int64_t`.
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
signed char i,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`i`
|
||
]
|
||
[
|
||
The initial value.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload11 value::value (11 of 35 overloads)]
|
||
|
||
Construct a `std::int64_t`.
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
short i,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`i`
|
||
]
|
||
[
|
||
The initial value.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload12 value::value (12 of 35 overloads)]
|
||
|
||
Construct a `std::int64_t`.
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
int i,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`i`
|
||
]
|
||
[
|
||
The initial value.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload13 value::value (13 of 35 overloads)]
|
||
|
||
Construct a `std::int64_t`.
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
long i,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`i`
|
||
]
|
||
[
|
||
The initial value.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload14 value::value (14 of 35 overloads)]
|
||
|
||
Construct a `std::int64_t`.
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
long long i,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`i`
|
||
]
|
||
[
|
||
The initial value.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload15 value::value (15 of 35 overloads)]
|
||
|
||
Construct a `std::uint64_t`.
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
unsigned char u,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`u`
|
||
]
|
||
[
|
||
The initial value.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload16 value::value (16 of 35 overloads)]
|
||
|
||
Construct a `std::uint64_t`.
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
unsigned short u,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`u`
|
||
]
|
||
[
|
||
The initial value.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload17 value::value (17 of 35 overloads)]
|
||
|
||
Construct a `std::uint64_t`.
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
unsigned int u,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`u`
|
||
]
|
||
[
|
||
The initial value.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload18 value::value (18 of 35 overloads)]
|
||
|
||
Construct a `std::uint64_t`.
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
unsigned long u,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`u`
|
||
]
|
||
[
|
||
The initial value.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload19 value::value (19 of 35 overloads)]
|
||
|
||
Construct a `std::uint64_t`.
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
unsigned long long u,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`u`
|
||
]
|
||
[
|
||
The initial value.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload20 value::value (20 of 35 overloads)]
|
||
|
||
Construct a `double`.
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
double d,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`d`
|
||
]
|
||
[
|
||
The initial value.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload21 value::value (21 of 35 overloads)]
|
||
|
||
Construct a [link json.ref.boost__json__string `string`].
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
string_view s,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
The string is constructed with a copy of the string view `s`, using the specified memory resource.
|
||
|
||
[heading Complexity]
|
||
Linear in `s.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The string view to construct with.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload22 value::value (22 of 35 overloads)]
|
||
|
||
Construct a [link json.ref.boost__json__string `string`].
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
char const* s,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
The string is constructed with a copy of the null-terminated string `s`, using the specified memory resource.
|
||
|
||
[heading Complexity]
|
||
Linear in `std::strlen(s)`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The null-terminated string to construct with.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload23 value::value (23 of 35 overloads)]
|
||
|
||
Construct a [link json.ref.boost__json__string `string`].
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
string other);
|
||
```
|
||
|
||
[heading Description]
|
||
The value is constructed from `other`, using the same memory resource. To transfer ownership, use `std::move`:
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
string str = "The Boost C++ Library Collection";
|
||
|
||
// transfer ownership
|
||
value jv( std::move(str) );
|
||
|
||
assert( str.empty() );
|
||
assert( *str.storage() == *jv.storage() );
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The string to construct with.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload24 value::value (24 of 35 overloads)]
|
||
|
||
Construct a [link json.ref.boost__json__string `string`].
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
string const& other,
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
The value is copy constructed from `other`, using the specified memory resource.
|
||
|
||
[heading Complexity]
|
||
Linear in `other.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The string to construct with.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload25 value::value (25 of 35 overloads)]
|
||
|
||
Construct a [link json.ref.boost__json__string `string`].
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
string&& other,
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
The value is move constructed from `other`, using the specified memory resource.
|
||
|
||
[heading Complexity]
|
||
Constant or linear in `other.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The string to construct with.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload26 value::value (26 of 35 overloads)]
|
||
|
||
Construct a [link json.ref.boost__json__string `string`].
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
string_kind_t,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
This is the fastest way to construct an empty string, using the specified memory resource. The variable [link json.ref.boost__json__string_kind `string_kind`] may be passed as the first parameter to select this overload:
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
// Construct an empty string
|
||
|
||
value jv( string_kind );
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
[heading See Also]
|
||
[link json.ref.boost__json__string_kind `string_kind`]
|
||
|
||
[endsect]
|
||
|
||
[section:overload27 value::value (27 of 35 overloads)]
|
||
|
||
Construct an [link json.ref.boost__json__array `array`].
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
array other);
|
||
```
|
||
|
||
[heading Description]
|
||
The value is constructed from `other`, using the same memory resource. To transfer ownership, use `std::move`:
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
array arr( {1, 2, 3, 4, 5} );
|
||
|
||
// transfer ownership
|
||
value jv( std::move(arr) );
|
||
|
||
assert( arr.empty() );
|
||
assert( *arr.storage() == *jv.storage() );
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The array to construct with.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload28 value::value (28 of 35 overloads)]
|
||
|
||
Construct an [link json.ref.boost__json__array `array`].
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
array const& other,
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
The value is copy constructed from `other`, using the specified memory resource.
|
||
|
||
[heading Complexity]
|
||
Linear in `other.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The array to construct with.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload29 value::value (29 of 35 overloads)]
|
||
|
||
Construct an [link json.ref.boost__json__array `array`].
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
array&& other,
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
The value is move-constructed from `other`, using the specified memory resource.
|
||
|
||
[heading Complexity]
|
||
Constant or linear in `other.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The array to construct with.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload30 value::value (30 of 35 overloads)]
|
||
|
||
Construct an [link json.ref.boost__json__array `array`].
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
array_kind_t,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
This is the fastest way to construct an empty array, using the specified memory resource. The variable [link json.ref.boost__json__array_kind `array_kind`] may be passed as the first parameter to select this overload:
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
// Construct an empty array
|
||
|
||
value jv( array_kind );
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
[heading See Also]
|
||
[link json.ref.boost__json__array_kind `array_kind`]
|
||
|
||
[endsect]
|
||
|
||
[section:overload31 value::value (31 of 35 overloads)]
|
||
|
||
Construct an [link json.ref.boost__json__object `object`].
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
object other);
|
||
```
|
||
|
||
[heading Description]
|
||
The value is constructed from `other`, using the same memory resource. To transfer ownership, use `std::move`:
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
object obj( {{"a",1}, {"b",2}, {"c"},3}} );
|
||
|
||
// transfer ownership
|
||
value jv( std::move(obj) );
|
||
|
||
assert( obj.empty() );
|
||
assert( *obj.storage() == *jv.storage() );
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The object to construct with.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload32 value::value (32 of 35 overloads)]
|
||
|
||
Construct an [link json.ref.boost__json__object `object`].
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
object const& other,
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
The value is copy constructed from `other`, using the specified memory resource.
|
||
|
||
[heading Complexity]
|
||
Linear in `other.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The object to construct with.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload33 value::value (33 of 35 overloads)]
|
||
|
||
Construct an [link json.ref.boost__json__object `object`].
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
object&& other,
|
||
storage_ptr sp);
|
||
```
|
||
|
||
[heading Description]
|
||
The value is move constructed from `other`, using the specified memory resource.
|
||
|
||
[heading Complexity]
|
||
Constant or linear in `other.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The object to construct with.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload34 value::value (34 of 35 overloads)]
|
||
|
||
Construct an [link json.ref.boost__json__object `object`].
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
object_kind_t,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
This is the fastest way to construct an empty object, using the specified memory resource. The variable [link json.ref.boost__json__object_kind `object_kind`] may be passed as the first parameter to select this overload:
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
// Construct an empty object
|
||
|
||
value jv( object_kind );
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
[heading See Also]
|
||
[link json.ref.boost__json__object_kind `object_kind`]
|
||
|
||
[endsect]
|
||
|
||
[section:overload35 value::value (35 of 35 overloads)]
|
||
|
||
Construct from an initializer-list.
|
||
[heading Synopsis]
|
||
```
|
||
value(
|
||
std::initializer_list< value_ref > init,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
If the initializer list consists of key/value pairs, an [link json.ref.boost__json__object `object`] is created. Otherwise an [link json.ref.boost__json__array `array`] is created. The contents of the initializer list are copied to the newly constructed value using the specified memory resource.
|
||
|
||
[heading Complexity]
|
||
Linear in `init.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`init`
|
||
]
|
||
[
|
||
The initializer list to construct from.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use. The container will acquire shared ownership of the memory resource.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:emplace_null value::emplace_null]
|
||
[indexterm2 emplace_null..value]
|
||
|
||
|
||
Change the kind to null, discarding the previous contents.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
emplace_null();
|
||
```
|
||
|
||
[heading Description]
|
||
The value is replaced with a null, destroying the previous contents.
|
||
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:emplace_bool value::emplace_bool]
|
||
[indexterm2 emplace_bool..value]
|
||
|
||
|
||
Return a reference to a `bool`, changing the kind and replacing the contents.
|
||
[heading Synopsis]
|
||
```
|
||
bool&
|
||
emplace_bool();
|
||
```
|
||
|
||
[heading Description]
|
||
The value is replaced with a `bool` initialized to `false`, destroying the previous contents.
|
||
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:emplace_int64 value::emplace_int64]
|
||
[indexterm2 emplace_int64..value]
|
||
|
||
|
||
Return a reference to a `std::int64_t`, changing the kind and replacing the contents.
|
||
[heading Synopsis]
|
||
```
|
||
std::int64_t&
|
||
emplace_int64();
|
||
```
|
||
|
||
[heading Description]
|
||
The value is replaced with a `std::int64_t` initialized to zero, destroying the previous contents.
|
||
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:emplace_uint64 value::emplace_uint64]
|
||
[indexterm2 emplace_uint64..value]
|
||
|
||
|
||
Return a reference to a `std::uint64_t`, changing the kind and replacing the contents.
|
||
[heading Synopsis]
|
||
```
|
||
std::uint64_t&
|
||
emplace_uint64();
|
||
```
|
||
|
||
[heading Description]
|
||
The value is replaced with a `std::uint64_t` initialized to zero, destroying the previous contents.
|
||
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:emplace_double value::emplace_double]
|
||
[indexterm2 emplace_double..value]
|
||
|
||
|
||
Return a reference to a `double`, changing the kind and replacing the contents.
|
||
[heading Synopsis]
|
||
```
|
||
double&
|
||
emplace_double();
|
||
```
|
||
|
||
[heading Description]
|
||
The value is replaced with a `double` initialized to zero, destroying the previous contents.
|
||
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:emplace_string value::emplace_string]
|
||
[indexterm2 emplace_string..value]
|
||
|
||
|
||
Return a reference to a [link json.ref.boost__json__string `string`], changing the kind and replacing the contents.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
emplace_string();
|
||
```
|
||
|
||
[heading Description]
|
||
The value is replaced with an empty [link json.ref.boost__json__string `string`] using the current memory resource, destroying the previous contents.
|
||
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:emplace_array value::emplace_array]
|
||
[indexterm2 emplace_array..value]
|
||
|
||
|
||
Return a reference to an [link json.ref.boost__json__array `array`], changing the kind and replacing the contents.
|
||
[heading Synopsis]
|
||
```
|
||
array&
|
||
emplace_array();
|
||
```
|
||
|
||
[heading Description]
|
||
The value is replaced with an empty [link json.ref.boost__json__array `array`] using the current memory resource, destroying the previous contents.
|
||
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:emplace_object value::emplace_object]
|
||
[indexterm2 emplace_object..value]
|
||
|
||
|
||
Return a reference to an [link json.ref.boost__json__object `object`], changing the kind and replacing the contents.
|
||
[heading Synopsis]
|
||
```
|
||
object&
|
||
emplace_object();
|
||
```
|
||
|
||
[heading Description]
|
||
The contents are replaced with an empty [link json.ref.boost__json__object `object`] using the current [link json.ref.boost__json__memory_resource `memory_resource`]. All previously obtained iterators and references obtained beforehand are invalidated.
|
||
|
||
[heading Complexity]
|
||
Linear in the size of `*this`.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:swap value::swap]
|
||
[indexterm2 swap..value]
|
||
|
||
|
||
Swap the given values.
|
||
```
|
||
void
|
||
``[link json.ref.boost__json__value.swap.overload1 swap]``(
|
||
value& other);
|
||
``[''''»''' [link json.ref.boost__json__value.swap.overload1 `more...`]]``
|
||
|
||
friend void
|
||
``[link json.ref.boost__json__value.swap.overload2 swap]``(
|
||
value& lhs,
|
||
value& rhs);
|
||
``[''''»''' [link json.ref.boost__json__value.swap.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::swap (1 of 2 overloads)]
|
||
|
||
Swap the given values.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
swap(
|
||
value& other);
|
||
```
|
||
|
||
[heading Description]
|
||
Exchanges the contents of this value with another value. Ownership of the respective [link json.ref.boost__json__memory_resource `memory_resource`] objects is not transferred:
|
||
|
||
* If `*other.storage() == *this->storage()`, ownership of the underlying memory is swapped in constant time, with no possibility of exceptions. All iterators and references remain valid.
|
||
|
||
* If `*other.storage() != *this->storage()`, the contents are logically swapped by making copies, which can throw. In this case all iterators and references are invalidated.
|
||
|
||
[heading Complexity]
|
||
Constant or linear in the sum of the sizes of the values.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`other`
|
||
]
|
||
[
|
||
The value to swap with. If `this == &other`, this function call has no effect.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::swap (2 of 2 overloads)]
|
||
|
||
Swap the given values.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/value.hpp]
|
||
|
||
```
|
||
friend void
|
||
swap(
|
||
value& lhs,
|
||
value& rhs);
|
||
```
|
||
|
||
[heading Description]
|
||
Exchanges the contents of value `lhs` with another value `rhs`. Ownership of the respective [link json.ref.boost__json__memory_resource `memory_resource`] objects is not transferred.
|
||
|
||
* If `*lhs.storage() == *rhs.storage()`, ownership of the underlying memory is swapped in constant time, with no possibility of exceptions. All iterators and references remain valid.
|
||
|
||
* If `*lhs.storage() != *rhs.storage`, the contents are logically swapped by a copy, which can throw. In this case all iterators and references are invalidated.
|
||
|
||
[heading Effects]
|
||
|
||
```
|
||
lhs.swap( rhs );
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant or linear in the sum of the sizes of the values.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`lhs`
|
||
]
|
||
[
|
||
The value to exchange.
|
||
]
|
||
]
|
||
[
|
||
[`rhs`
|
||
]
|
||
[
|
||
The value to exchange. If `&lhs == &rhs`, this function call has no effect.
|
||
]
|
||
]
|
||
]
|
||
[heading See Also]
|
||
[link json.ref.boost__json__value.swap `value::swap`]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:kind value::kind]
|
||
[indexterm2 kind..value]
|
||
|
||
|
||
Returns the kind of this JSON value.
|
||
[heading Synopsis]
|
||
```
|
||
json::kind
|
||
kind() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns the discriminating enumeration constant of type [link json.ref.boost__json__kind `json::kind`] corresponding to the underlying representation stored in the container.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:is_array value::is_array]
|
||
[indexterm2 is_array..value]
|
||
|
||
|
||
Return `true` if this is an array.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
is_array() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function is used to determine if the underlying representation is a certain kind.
|
||
|
||
[heading Effects]
|
||
|
||
```
|
||
return this->kind() == kind::array;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:is_object value::is_object]
|
||
[indexterm2 is_object..value]
|
||
|
||
|
||
Return `true` if this is an object.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
is_object() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function is used to determine if the underlying representation is a certain kind.
|
||
|
||
[heading Effects]
|
||
|
||
```
|
||
return this->kind() == kind::object;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:is_string value::is_string]
|
||
[indexterm2 is_string..value]
|
||
|
||
|
||
Return `true` if this is a string.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
is_string() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function is used to determine if the underlying representation is a certain kind.
|
||
|
||
[heading Effects]
|
||
|
||
```
|
||
return this->kind() == kind::string;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:is_int64 value::is_int64]
|
||
[indexterm2 is_int64..value]
|
||
|
||
|
||
Return `true` if this is a signed integer.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
is_int64() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function is used to determine if the underlying representation is a certain kind.
|
||
|
||
[heading Effects]
|
||
|
||
```
|
||
return this->kind() == kind::int64;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:is_uint64 value::is_uint64]
|
||
[indexterm2 is_uint64..value]
|
||
|
||
|
||
Return `true` if this is a unsigned integer.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
is_uint64() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function is used to determine if the underlying representation is a certain kind.
|
||
|
||
[heading Effects]
|
||
|
||
```
|
||
return this->kind() == kind::uint64;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:is_double value::is_double]
|
||
[indexterm2 is_double..value]
|
||
|
||
|
||
Return `true` if this is a double.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
is_double() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function is used to determine if the underlying representation is a certain kind.
|
||
|
||
[heading Effects]
|
||
|
||
```
|
||
return this->kind() == kind::double_;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:is_bool value::is_bool]
|
||
[indexterm2 is_bool..value]
|
||
|
||
|
||
Return `true` if this is a bool.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
is_bool() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function is used to determine if the underlying representation is a certain kind.
|
||
|
||
[heading Effects]
|
||
|
||
```
|
||
return this->kind() == kind::bool_;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:is_null value::is_null]
|
||
[indexterm2 is_null..value]
|
||
|
||
|
||
Returns true if this is a null.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
is_null() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function is used to determine if the underlying representation is a certain kind.
|
||
|
||
[heading Effects]
|
||
|
||
```
|
||
return this->kind() == kind::null;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:is_structured value::is_structured]
|
||
[indexterm2 is_structured..value]
|
||
|
||
|
||
Returns true if this is an array or object.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
is_structured() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns `true` if [link json.ref.boost__json__value.kind `kind()`] is either `kind::object` or `kind::array`.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:is_primitive value::is_primitive]
|
||
[indexterm2 is_primitive..value]
|
||
|
||
|
||
Returns true if this is not an array or object.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
is_primitive() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns `true` if [link json.ref.boost__json__value.kind `kind()`] is neither `kind::object` nor `kind::array`.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:is_number value::is_number]
|
||
[indexterm2 is_number..value]
|
||
|
||
|
||
Returns true if this is a number.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
is_number() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns `true` when [link json.ref.boost__json__value.kind `kind()`] is one of the following values: `kind::int64`, `kind::uint64`, or `kind::double_`.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:if_array value::if_array]
|
||
[indexterm2 if_array..value]
|
||
|
||
|
||
Return an [link json.ref.boost__json__array `array`] pointer if this is an array, else return `nullptr`
|
||
```
|
||
array const*
|
||
``[link json.ref.boost__json__value.if_array.overload1 if_array]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.if_array.overload1 `more...`]]``
|
||
|
||
array*
|
||
``[link json.ref.boost__json__value.if_array.overload2 if_array]``();
|
||
``[''''»''' [link json.ref.boost__json__value.if_array.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::if_array (1 of 2 overloads)]
|
||
|
||
Return an [link json.ref.boost__json__array `array`] pointer if this is an array, else return `nullptr`
|
||
[heading Synopsis]
|
||
```
|
||
array const*
|
||
if_array() const;
|
||
```
|
||
|
||
[heading Description]
|
||
If `this->kind() == kind::array`, returns a pointer to the underlying array. Otherwise, returns `nullptr`.
|
||
|
||
[heading Example]
|
||
|
||
The return value is used in both a boolean context and to assign a variable:
|
||
```
|
||
if( auto p = jv.if_array() )
|
||
return *p;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::if_array (2 of 2 overloads)]
|
||
|
||
Return an [link json.ref.boost__json__array `array`] pointer if this is an array, else return `nullptr`
|
||
[heading Synopsis]
|
||
```
|
||
array*
|
||
if_array();
|
||
```
|
||
|
||
[heading Description]
|
||
If `this->kind() == kind::array`, returns a pointer to the underlying array. Otherwise, returns `nullptr`.
|
||
|
||
[heading Example]
|
||
|
||
The return value is used in both a boolean context and to assign a variable:
|
||
```
|
||
if( auto p = jv.if_array() )
|
||
return *p;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:if_object value::if_object]
|
||
[indexterm2 if_object..value]
|
||
|
||
|
||
Return an [link json.ref.boost__json__object `object`] pointer if this is an object, else return `nullptr`
|
||
```
|
||
object const*
|
||
``[link json.ref.boost__json__value.if_object.overload1 if_object]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.if_object.overload1 `more...`]]``
|
||
|
||
object*
|
||
``[link json.ref.boost__json__value.if_object.overload2 if_object]``();
|
||
``[''''»''' [link json.ref.boost__json__value.if_object.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::if_object (1 of 2 overloads)]
|
||
|
||
Return an [link json.ref.boost__json__object `object`] pointer if this is an object, else return `nullptr`
|
||
[heading Synopsis]
|
||
```
|
||
object const*
|
||
if_object() const;
|
||
```
|
||
|
||
[heading Description]
|
||
If `this->kind() == kind::object`, returns a pointer to the underlying object. Otherwise, returns `nullptr`.
|
||
|
||
[heading Example]
|
||
|
||
The return value is used in both a boolean context and to assign a variable:
|
||
```
|
||
if( auto p = jv.if_object() )
|
||
return *p;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::if_object (2 of 2 overloads)]
|
||
|
||
Return an [link json.ref.boost__json__object `object`] pointer if this is an object, else return `nullptr`
|
||
[heading Synopsis]
|
||
```
|
||
object*
|
||
if_object();
|
||
```
|
||
|
||
[heading Description]
|
||
If `this->kind() == kind::object`, returns a pointer to the underlying object. Otherwise, returns `nullptr`.
|
||
|
||
[heading Example]
|
||
|
||
The return value is used in both a boolean context and to assign a variable:
|
||
```
|
||
if( auto p = jv.if_object() )
|
||
return *p;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:if_string value::if_string]
|
||
[indexterm2 if_string..value]
|
||
|
||
|
||
Return a [link json.ref.boost__json__string `string`] pointer if this is a string, else return `nullptr`
|
||
```
|
||
string const*
|
||
``[link json.ref.boost__json__value.if_string.overload1 if_string]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.if_string.overload1 `more...`]]``
|
||
|
||
string*
|
||
``[link json.ref.boost__json__value.if_string.overload2 if_string]``();
|
||
``[''''»''' [link json.ref.boost__json__value.if_string.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::if_string (1 of 2 overloads)]
|
||
|
||
Return a [link json.ref.boost__json__string `string`] pointer if this is a string, else return `nullptr`
|
||
[heading Synopsis]
|
||
```
|
||
string const*
|
||
if_string() const;
|
||
```
|
||
|
||
[heading Description]
|
||
If `this->kind() == kind::string`, returns a pointer to the underlying object. Otherwise, returns `nullptr`.
|
||
|
||
[heading Example]
|
||
|
||
The return value is used in both a boolean context and to assign a variable:
|
||
```
|
||
if( auto p = jv.if_string() )
|
||
return *p;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::if_string (2 of 2 overloads)]
|
||
|
||
Return a [link json.ref.boost__json__string `string`] pointer if this is a string, else return `nullptr`
|
||
[heading Synopsis]
|
||
```
|
||
string*
|
||
if_string();
|
||
```
|
||
|
||
[heading Description]
|
||
If `this->kind() == kind::string`, returns a pointer to the underlying object. Otherwise, returns `nullptr`.
|
||
|
||
[heading Example]
|
||
|
||
The return value is used in both a boolean context and to assign a variable:
|
||
```
|
||
if( auto p = jv.if_string() )
|
||
return *p;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:if_int64 value::if_int64]
|
||
[indexterm2 if_int64..value]
|
||
|
||
|
||
Return an `int64_t` pointer if this is a signed integer, else return `nullptr`
|
||
```
|
||
std::int64_t const*
|
||
``[link json.ref.boost__json__value.if_int64.overload1 if_int64]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.if_int64.overload1 `more...`]]``
|
||
|
||
std::int64_t*
|
||
``[link json.ref.boost__json__value.if_int64.overload2 if_int64]``();
|
||
``[''''»''' [link json.ref.boost__json__value.if_int64.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::if_int64 (1 of 2 overloads)]
|
||
|
||
Return an `int64_t` pointer if this is a signed integer, else return `nullptr`
|
||
[heading Synopsis]
|
||
```
|
||
std::int64_t const*
|
||
if_int64() const;
|
||
```
|
||
|
||
[heading Description]
|
||
If `this->kind() == kind::int64`, returns a pointer to the underlying integer. Otherwise, returns `nullptr`.
|
||
|
||
[heading Example]
|
||
|
||
The return value is used in both a boolean context and to assign a variable:
|
||
```
|
||
if( auto p = jv.if_int64() )
|
||
return *p;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::if_int64 (2 of 2 overloads)]
|
||
|
||
Return an `int64_t` pointer if this is a signed integer, else return `nullptr`
|
||
[heading Synopsis]
|
||
```
|
||
std::int64_t*
|
||
if_int64();
|
||
```
|
||
|
||
[heading Description]
|
||
If `this->kind() == kind::int64`, returns a pointer to the underlying integer. Otherwise, returns `nullptr`.
|
||
|
||
[heading Example]
|
||
|
||
The return value is used in both a boolean context and to assign a variable:
|
||
```
|
||
if( auto p = jv.if_int64() )
|
||
return *p;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:if_uint64 value::if_uint64]
|
||
[indexterm2 if_uint64..value]
|
||
|
||
|
||
Return a `uint64_t` pointer if this is an unsigned integer, else return `nullptr`
|
||
```
|
||
std::uint64_t const*
|
||
``[link json.ref.boost__json__value.if_uint64.overload1 if_uint64]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.if_uint64.overload1 `more...`]]``
|
||
|
||
std::uint64_t*
|
||
``[link json.ref.boost__json__value.if_uint64.overload2 if_uint64]``();
|
||
``[''''»''' [link json.ref.boost__json__value.if_uint64.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::if_uint64 (1 of 2 overloads)]
|
||
|
||
Return a `uint64_t` pointer if this is an unsigned integer, else return `nullptr`
|
||
[heading Synopsis]
|
||
```
|
||
std::uint64_t const*
|
||
if_uint64() const;
|
||
```
|
||
|
||
[heading Description]
|
||
If `this->kind() == kind::uint64`, returns a pointer to the underlying unsigned integer. Otherwise, returns `nullptr`.
|
||
|
||
[heading Example]
|
||
|
||
The return value is used in both a boolean context and to assign a variable:
|
||
```
|
||
if( auto p = jv.if_uint64() )
|
||
return *p;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::if_uint64 (2 of 2 overloads)]
|
||
|
||
Return a `uint64_t` pointer if this is an unsigned integer, else return `nullptr`
|
||
[heading Synopsis]
|
||
```
|
||
std::uint64_t*
|
||
if_uint64();
|
||
```
|
||
|
||
[heading Description]
|
||
If `this->kind() == kind::uint64`, returns a pointer to the underlying unsigned integer. Otherwise, returns `nullptr`.
|
||
|
||
[heading Example]
|
||
|
||
The return value is used in both a boolean context and to assign a variable:
|
||
```
|
||
if( auto p = jv.if_uint64() )
|
||
return *p;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:if_double value::if_double]
|
||
[indexterm2 if_double..value]
|
||
|
||
|
||
Return a `double` pointer if this is a double, else return `nullptr`
|
||
```
|
||
double const*
|
||
``[link json.ref.boost__json__value.if_double.overload1 if_double]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.if_double.overload1 `more...`]]``
|
||
|
||
double*
|
||
``[link json.ref.boost__json__value.if_double.overload2 if_double]``();
|
||
``[''''»''' [link json.ref.boost__json__value.if_double.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::if_double (1 of 2 overloads)]
|
||
|
||
Return a `double` pointer if this is a double, else return `nullptr`
|
||
[heading Synopsis]
|
||
```
|
||
double const*
|
||
if_double() const;
|
||
```
|
||
|
||
[heading Description]
|
||
If `this->kind() == kind::double_`, returns a pointer to the underlying double. Otherwise, returns `nullptr`.
|
||
|
||
[heading Example]
|
||
|
||
The return value is used in both a boolean context and to assign a variable:
|
||
```
|
||
if( auto p = jv.if_double() )
|
||
return *p;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::if_double (2 of 2 overloads)]
|
||
|
||
Return a `double` pointer if this is a double, else return `nullptr`
|
||
[heading Synopsis]
|
||
```
|
||
double*
|
||
if_double();
|
||
```
|
||
|
||
[heading Description]
|
||
If `this->kind() == kind::double_`, returns a pointer to the underlying double. Otherwise, returns `nullptr`.
|
||
|
||
[heading Example]
|
||
|
||
The return value is used in both a boolean context and to assign a variable:
|
||
```
|
||
if( auto p = jv.if_double() )
|
||
return *p;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:if_bool value::if_bool]
|
||
[indexterm2 if_bool..value]
|
||
|
||
|
||
Return a `bool` pointer if this is a boolean, else return `nullptr`
|
||
```
|
||
bool const*
|
||
``[link json.ref.boost__json__value.if_bool.overload1 if_bool]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.if_bool.overload1 `more...`]]``
|
||
|
||
bool*
|
||
``[link json.ref.boost__json__value.if_bool.overload2 if_bool]``();
|
||
``[''''»''' [link json.ref.boost__json__value.if_bool.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::if_bool (1 of 2 overloads)]
|
||
|
||
Return a `bool` pointer if this is a boolean, else return `nullptr`
|
||
[heading Synopsis]
|
||
```
|
||
bool const*
|
||
if_bool() const;
|
||
```
|
||
|
||
[heading Description]
|
||
If `this->kind() == kind::bool_`, returns a pointer to the underlying boolean. Otherwise, returns `nullptr`.
|
||
|
||
[heading Example]
|
||
|
||
The return value is used in both a boolean context and to assign a variable:
|
||
```
|
||
if( auto p = jv.if_bool() )
|
||
return *p;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::if_bool (2 of 2 overloads)]
|
||
|
||
Return a `bool` pointer if this is a boolean, else return `nullptr`
|
||
[heading Synopsis]
|
||
```
|
||
bool*
|
||
if_bool();
|
||
```
|
||
|
||
[heading Description]
|
||
If `this->kind() == kind::bool_`, returns a pointer to the underlying boolean. Otherwise, returns `nullptr`.
|
||
|
||
[heading Example]
|
||
|
||
The return value is used in both a boolean context and to assign a variable:
|
||
```
|
||
if( auto p = jv.if_bool() )
|
||
return *p;
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:to_number value::to_number]
|
||
[indexterm2 to_number..value]
|
||
|
||
|
||
Return the stored number cast to an arithmetic type.
|
||
```
|
||
template<
|
||
class T>
|
||
T
|
||
``[link json.ref.boost__json__value.to_number.overload1 to_number]``(
|
||
error_code& ec) const;
|
||
``[''''»''' [link json.ref.boost__json__value.to_number.overload1 `more...`]]``
|
||
|
||
template<
|
||
class T>
|
||
T
|
||
``[link json.ref.boost__json__value.to_number.overload2 to_number]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.to_number.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::to_number (1 of 2 overloads)]
|
||
|
||
Return the stored number cast to an arithmetic type.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class T>
|
||
T
|
||
to_number(
|
||
error_code& ec) const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function attempts to return the stored value converted to the arithmetic type `T` which may not be `bool`:
|
||
|
||
* If `T` is an integral type and the stored value is a number which can be losslessly converted, the conversion is performed without error and the converted number is returned.
|
||
|
||
* If `T` is an integral type and the stored value is a number which cannot be losslessly converted, then the operation fails with an error.
|
||
|
||
* If `T` is a floating point type and the stored value is a number, the conversion is performed without error. The converted number is returned, with a possible loss of precision.
|
||
|
||
* Otherwise, if the stored value is not a number; that is, if `this->is_number()` returns `false`, then the operation fails with an error.
|
||
|
||
[heading Constraints]
|
||
|
||
```
|
||
std::is_arithmetic< T >::value && ! std::is_same< T, bool >::value
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
[heading Return Value]
|
||
The converted number.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`ec`
|
||
]
|
||
[
|
||
Set to the error, if any occurred.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::to_number (2 of 2 overloads)]
|
||
|
||
Return the stored number cast to an arithmetic type.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class T>
|
||
T
|
||
to_number() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function attempts to return the stored value converted to the arithmetic type `T` which may not be `bool`:
|
||
|
||
* If `T` is an integral type and the stored value is a number which can be losslessly converted, the conversion is performed without error and the converted number is returned.
|
||
|
||
* If `T` is an integral type and the stored value is a number which cannot be losslessly converted, then the operation fails with an error.
|
||
|
||
* If `T` is a floating point type and the stored value is a number, the conversion is performed without error. The converted number is returned, with a possible loss of precision.
|
||
|
||
* Otherwise, if the stored value is not a number; that is, if `this->is_number()` returns `false`, then the operation fails with an error.
|
||
|
||
[heading Constraints]
|
||
|
||
```
|
||
std::is_arithmetic< T >::value && ! std::is_same< T, bool >::value
|
||
```
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Return Value]
|
||
The converted number.
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`system_error`
|
||
]
|
||
[
|
||
on error.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:storage value::storage]
|
||
[indexterm2 storage..value]
|
||
|
||
|
||
Return the memory resource associated with the value.
|
||
[heading Synopsis]
|
||
```
|
||
storage_ptr const&
|
||
storage() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This returns a pointer to the memory resource that was used to construct the value.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:get_allocator value::get_allocator]
|
||
[indexterm2 get_allocator..value]
|
||
|
||
|
||
Return the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
[heading Synopsis]
|
||
```
|
||
allocator_type
|
||
get_allocator() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns an instance of [link json.ref.boost__json__polymorphic_allocator `polymorphic_allocator`] constructed from the associated [link json.ref.boost__json__memory_resource `memory_resource`].
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:as_object value::as_object]
|
||
[indexterm2 as_object..value]
|
||
|
||
|
||
Return a reference to the underlying `object`, or throw an exception.
|
||
```
|
||
object&
|
||
``[link json.ref.boost__json__value.as_object.overload1 as_object]``();
|
||
``[''''»''' [link json.ref.boost__json__value.as_object.overload1 `more...`]]``
|
||
|
||
object const&
|
||
``[link json.ref.boost__json__value.as_object.overload2 as_object]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.as_object.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::as_object (1 of 2 overloads)]
|
||
|
||
Return a reference to the underlying `object`, or throw an exception.
|
||
[heading Synopsis]
|
||
```
|
||
object&
|
||
as_object();
|
||
```
|
||
|
||
[heading Description]
|
||
If [link json.ref.boost__json__value.is_object `is_object()`] is `true`, returns a reference to the underlying [link json.ref.boost__json__object `object`], otherwise throws an exception.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::invalid_argument`
|
||
]
|
||
[
|
||
`! this->is_object()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::as_object (2 of 2 overloads)]
|
||
|
||
Return a reference to the underlying `object`, or throw an exception.
|
||
[heading Synopsis]
|
||
```
|
||
object const&
|
||
as_object() const;
|
||
```
|
||
|
||
[heading Description]
|
||
If [link json.ref.boost__json__value.is_object `is_object()`] is `true`, returns a reference to the underlying [link json.ref.boost__json__object `object`], otherwise throws an exception.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::invalid_argument`
|
||
]
|
||
[
|
||
`! this->is_object()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:as_array value::as_array]
|
||
[indexterm2 as_array..value]
|
||
|
||
|
||
Return a reference to the underlying [link json.ref.boost__json__array `array`], or throw an exception.
|
||
```
|
||
array&
|
||
``[link json.ref.boost__json__value.as_array.overload1 as_array]``();
|
||
``[''''»''' [link json.ref.boost__json__value.as_array.overload1 `more...`]]``
|
||
|
||
array const&
|
||
``[link json.ref.boost__json__value.as_array.overload2 as_array]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.as_array.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::as_array (1 of 2 overloads)]
|
||
|
||
Return a reference to the underlying [link json.ref.boost__json__array `array`], or throw an exception.
|
||
[heading Synopsis]
|
||
```
|
||
array&
|
||
as_array();
|
||
```
|
||
|
||
[heading Description]
|
||
If [link json.ref.boost__json__value.is_array `is_array()`] is `true`, returns a reference to the underlying [link json.ref.boost__json__array `array`], otherwise throws an exception.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::invalid_argument`
|
||
]
|
||
[
|
||
`! this->is_array()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::as_array (2 of 2 overloads)]
|
||
|
||
Return a reference to the underlying `array`, or throw an exception.
|
||
[heading Synopsis]
|
||
```
|
||
array const&
|
||
as_array() const;
|
||
```
|
||
|
||
[heading Description]
|
||
If [link json.ref.boost__json__value.is_array `is_array()`] is `true`, returns a reference to the underlying [link json.ref.boost__json__array `array`], otherwise throws an exception.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::invalid_argument`
|
||
]
|
||
[
|
||
`! this->is_array()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:as_string value::as_string]
|
||
[indexterm2 as_string..value]
|
||
|
||
|
||
Return a reference to the underlying `string`, or throw an exception.
|
||
```
|
||
string&
|
||
``[link json.ref.boost__json__value.as_string.overload1 as_string]``();
|
||
``[''''»''' [link json.ref.boost__json__value.as_string.overload1 `more...`]]``
|
||
|
||
string const&
|
||
``[link json.ref.boost__json__value.as_string.overload2 as_string]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.as_string.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::as_string (1 of 2 overloads)]
|
||
|
||
Return a reference to the underlying `string`, or throw an exception.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
as_string();
|
||
```
|
||
|
||
[heading Description]
|
||
If [link json.ref.boost__json__value.is_string `is_string()`] is `true`, returns a reference to the underlying [link json.ref.boost__json__string `string`], otherwise throws an exception.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::invalid_argument`
|
||
]
|
||
[
|
||
`! this->is_string()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::as_string (2 of 2 overloads)]
|
||
|
||
Return a reference to the underlying `string`, or throw an exception.
|
||
[heading Synopsis]
|
||
```
|
||
string const&
|
||
as_string() const;
|
||
```
|
||
|
||
[heading Description]
|
||
If [link json.ref.boost__json__value.is_string `is_string()`] is `true`, returns a reference to the underlying [link json.ref.boost__json__string `string`], otherwise throws an exception.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::invalid_argument`
|
||
]
|
||
[
|
||
`! this->is_string()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:as_int64 value::as_int64]
|
||
[indexterm2 as_int64..value]
|
||
|
||
|
||
Return a reference to the underlying `std::int64_t`, or throw an exception.
|
||
```
|
||
std::int64_t&
|
||
``[link json.ref.boost__json__value.as_int64.overload1 as_int64]``();
|
||
``[''''»''' [link json.ref.boost__json__value.as_int64.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Return the underlying `std::int64_t`, or throw an exception.
|
||
```
|
||
std::int64_t
|
||
``[link json.ref.boost__json__value.as_int64.overload2 as_int64]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.as_int64.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::as_int64 (1 of 2 overloads)]
|
||
|
||
Return a reference to the underlying `std::int64_t`, or throw an exception.
|
||
[heading Synopsis]
|
||
```
|
||
std::int64_t&
|
||
as_int64();
|
||
```
|
||
|
||
[heading Description]
|
||
If [link json.ref.boost__json__value.is_int64 `is_int64()`] is `true`, returns a reference to the underlying `std::int64_t`, otherwise throws an exception.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::invalid_argument`
|
||
]
|
||
[
|
||
`! this->is_int64()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::as_int64 (2 of 2 overloads)]
|
||
|
||
Return the underlying `std::int64_t`, or throw an exception.
|
||
[heading Synopsis]
|
||
```
|
||
std::int64_t
|
||
as_int64() const;
|
||
```
|
||
|
||
[heading Description]
|
||
If [link json.ref.boost__json__value.is_int64 `is_int64()`] is `true`, returns the underlying `std::int64_t`, otherwise throws an exception.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::invalid_argument`
|
||
]
|
||
[
|
||
`! this->is_int64()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:as_uint64 value::as_uint64]
|
||
[indexterm2 as_uint64..value]
|
||
|
||
|
||
Return a reference to the underlying `std::uint64_t`, or throw an exception.
|
||
```
|
||
std::uint64_t&
|
||
``[link json.ref.boost__json__value.as_uint64.overload1 as_uint64]``();
|
||
``[''''»''' [link json.ref.boost__json__value.as_uint64.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Return the underlying `std::uint64_t`, or throw an exception.
|
||
```
|
||
std::uint64_t
|
||
``[link json.ref.boost__json__value.as_uint64.overload2 as_uint64]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.as_uint64.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::as_uint64 (1 of 2 overloads)]
|
||
|
||
Return a reference to the underlying `std::uint64_t`, or throw an exception.
|
||
[heading Synopsis]
|
||
```
|
||
std::uint64_t&
|
||
as_uint64();
|
||
```
|
||
|
||
[heading Description]
|
||
If [link json.ref.boost__json__value.is_uint64 `is_uint64()`] is `true`, returns a reference to the underlying `std::uint64_t`, otherwise throws an exception.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::invalid_argument`
|
||
]
|
||
[
|
||
`! this->is_uint64()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::as_uint64 (2 of 2 overloads)]
|
||
|
||
Return the underlying `std::uint64_t`, or throw an exception.
|
||
[heading Synopsis]
|
||
```
|
||
std::uint64_t
|
||
as_uint64() const;
|
||
```
|
||
|
||
[heading Description]
|
||
If [link json.ref.boost__json__value.is_int64 `is_int64()`] is `true`, returns the underlying `std::uint64_t`, otherwise throws an exception.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::length_error`
|
||
]
|
||
[
|
||
`! this->is_uint64()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:as_double value::as_double]
|
||
[indexterm2 as_double..value]
|
||
|
||
|
||
Return a reference to the underlying `double`, or throw an exception.
|
||
```
|
||
double&
|
||
``[link json.ref.boost__json__value.as_double.overload1 as_double]``();
|
||
``[''''»''' [link json.ref.boost__json__value.as_double.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Return the underlying `double`, or throw an exception.
|
||
```
|
||
double
|
||
``[link json.ref.boost__json__value.as_double.overload2 as_double]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.as_double.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::as_double (1 of 2 overloads)]
|
||
|
||
Return a reference to the underlying `double`, or throw an exception.
|
||
[heading Synopsis]
|
||
```
|
||
double&
|
||
as_double();
|
||
```
|
||
|
||
[heading Description]
|
||
If [link json.ref.boost__json__value.is_double `is_double()`] is `true`, returns a reference to the underlying `double`, otherwise throws an exception.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::invalid_argument`
|
||
]
|
||
[
|
||
`! this->is_double()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::as_double (2 of 2 overloads)]
|
||
|
||
Return the underlying `double`, or throw an exception.
|
||
[heading Synopsis]
|
||
```
|
||
double
|
||
as_double() const;
|
||
```
|
||
|
||
[heading Description]
|
||
If [link json.ref.boost__json__value.is_int64 `is_int64()`] is `true`, returns the underlying `double`, otherwise throws an exception.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::invalid_argument`
|
||
]
|
||
[
|
||
`! this->is_double()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:as_bool value::as_bool]
|
||
[indexterm2 as_bool..value]
|
||
|
||
|
||
Return a reference to the underlying `bool`, or throw an exception.
|
||
```
|
||
bool&
|
||
``[link json.ref.boost__json__value.as_bool.overload1 as_bool]``();
|
||
``[''''»''' [link json.ref.boost__json__value.as_bool.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Return the underlying `bool`, or throw an exception.
|
||
```
|
||
bool
|
||
``[link json.ref.boost__json__value.as_bool.overload2 as_bool]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.as_bool.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::as_bool (1 of 2 overloads)]
|
||
|
||
Return a reference to the underlying `bool`, or throw an exception.
|
||
[heading Synopsis]
|
||
```
|
||
bool&
|
||
as_bool();
|
||
```
|
||
|
||
[heading Description]
|
||
If [link json.ref.boost__json__value.is_bool `is_bool()`] is `true`, returns a reference to the underlying `bool`, otherwise throws an exception.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::invalid_argument`
|
||
]
|
||
[
|
||
`! this->is_bool()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::as_bool (2 of 2 overloads)]
|
||
|
||
Return the underlying `bool`, or throw an exception.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
as_bool() const;
|
||
```
|
||
|
||
[heading Description]
|
||
If [link json.ref.boost__json__value.is_bool `is_bool()`] is `true`, returns the underlying `bool`, otherwise throws an exception.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`std::invalid_argument`
|
||
]
|
||
[
|
||
`! this->is_bool()`
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:get_object value::get_object]
|
||
[indexterm2 get_object..value]
|
||
|
||
|
||
Return a reference to the underlying `object`, without checking.
|
||
```
|
||
object&
|
||
``[link json.ref.boost__json__value.get_object.overload1 get_object]``();
|
||
``[''''»''' [link json.ref.boost__json__value.get_object.overload1 `more...`]]``
|
||
|
||
object const&
|
||
``[link json.ref.boost__json__value.get_object.overload2 get_object]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.get_object.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::get_object (1 of 2 overloads)]
|
||
|
||
Return a reference to the underlying `object`, without checking.
|
||
[heading Synopsis]
|
||
```
|
||
object&
|
||
get_object();
|
||
```
|
||
|
||
[heading Description]
|
||
This is the fastest way to access the underlying representation when the kind is known in advance.
|
||
|
||
[heading Preconditions]
|
||
|
||
```
|
||
this->is_object()
|
||
```
|
||
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::get_object (2 of 2 overloads)]
|
||
|
||
Return a reference to the underlying `object`, without checking.
|
||
[heading Synopsis]
|
||
```
|
||
object const&
|
||
get_object() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This is the fastest way to access the underlying representation when the kind is known in advance.
|
||
|
||
[heading Preconditions]
|
||
|
||
```
|
||
this->is_object()
|
||
```
|
||
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:get_array value::get_array]
|
||
[indexterm2 get_array..value]
|
||
|
||
|
||
Return a reference to the underlying `array`, without checking.
|
||
```
|
||
array&
|
||
``[link json.ref.boost__json__value.get_array.overload1 get_array]``();
|
||
``[''''»''' [link json.ref.boost__json__value.get_array.overload1 `more...`]]``
|
||
|
||
array const&
|
||
``[link json.ref.boost__json__value.get_array.overload2 get_array]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.get_array.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::get_array (1 of 2 overloads)]
|
||
|
||
Return a reference to the underlying `array`, without checking.
|
||
[heading Synopsis]
|
||
```
|
||
array&
|
||
get_array();
|
||
```
|
||
|
||
[heading Description]
|
||
This is the fastest way to access the underlying representation when the kind is known in advance.
|
||
|
||
[heading Preconditions]
|
||
|
||
```
|
||
this->is_array()
|
||
```
|
||
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::get_array (2 of 2 overloads)]
|
||
|
||
Return a reference to the underlying `array`, without checking.
|
||
[heading Synopsis]
|
||
```
|
||
array const&
|
||
get_array() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This is the fastest way to access the underlying representation when the kind is known in advance.
|
||
|
||
[heading Preconditions]
|
||
|
||
```
|
||
this->is_array()
|
||
```
|
||
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:get_string value::get_string]
|
||
[indexterm2 get_string..value]
|
||
|
||
|
||
Return a reference to the underlying `string`, without checking.
|
||
```
|
||
string&
|
||
``[link json.ref.boost__json__value.get_string.overload1 get_string]``();
|
||
``[''''»''' [link json.ref.boost__json__value.get_string.overload1 `more...`]]``
|
||
|
||
string const&
|
||
``[link json.ref.boost__json__value.get_string.overload2 get_string]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.get_string.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::get_string (1 of 2 overloads)]
|
||
|
||
Return a reference to the underlying `string`, without checking.
|
||
[heading Synopsis]
|
||
```
|
||
string&
|
||
get_string();
|
||
```
|
||
|
||
[heading Description]
|
||
This is the fastest way to access the underlying representation when the kind is known in advance.
|
||
|
||
[heading Preconditions]
|
||
|
||
```
|
||
this->is_string()
|
||
```
|
||
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::get_string (2 of 2 overloads)]
|
||
|
||
Return a reference to the underlying `string`, without checking.
|
||
[heading Synopsis]
|
||
```
|
||
string const&
|
||
get_string() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This is the fastest way to access the underlying representation when the kind is known in advance.
|
||
|
||
[heading Preconditions]
|
||
|
||
```
|
||
this->is_string()
|
||
```
|
||
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:get_int64 value::get_int64]
|
||
[indexterm2 get_int64..value]
|
||
|
||
|
||
Return a reference to the underlying `std::int64_t`, without checking.
|
||
```
|
||
std::int64_t&
|
||
``[link json.ref.boost__json__value.get_int64.overload1 get_int64]``();
|
||
``[''''»''' [link json.ref.boost__json__value.get_int64.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Return the underlying `std::int64_t`, without checking.
|
||
```
|
||
std::int64_t
|
||
``[link json.ref.boost__json__value.get_int64.overload2 get_int64]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.get_int64.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::get_int64 (1 of 2 overloads)]
|
||
|
||
Return a reference to the underlying `std::int64_t`, without checking.
|
||
[heading Synopsis]
|
||
```
|
||
std::int64_t&
|
||
get_int64();
|
||
```
|
||
|
||
[heading Description]
|
||
This is the fastest way to access the underlying representation when the kind is known in advance.
|
||
|
||
[heading Preconditions]
|
||
|
||
```
|
||
this->is_int64()
|
||
```
|
||
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::get_int64 (2 of 2 overloads)]
|
||
|
||
Return the underlying `std::int64_t`, without checking.
|
||
[heading Synopsis]
|
||
```
|
||
std::int64_t
|
||
get_int64() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This is the fastest way to access the underlying representation when the kind is known in advance.
|
||
|
||
[heading Preconditions]
|
||
|
||
```
|
||
this->is_int64()
|
||
```
|
||
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:get_uint64 value::get_uint64]
|
||
[indexterm2 get_uint64..value]
|
||
|
||
|
||
Return a reference to the underlying `std::uint64_t`, without checking.
|
||
```
|
||
std::uint64_t&
|
||
``[link json.ref.boost__json__value.get_uint64.overload1 get_uint64]``();
|
||
``[''''»''' [link json.ref.boost__json__value.get_uint64.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Return the underlying `std::uint64_t`, without checking.
|
||
```
|
||
std::uint64_t
|
||
``[link json.ref.boost__json__value.get_uint64.overload2 get_uint64]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.get_uint64.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::get_uint64 (1 of 2 overloads)]
|
||
|
||
Return a reference to the underlying `std::uint64_t`, without checking.
|
||
[heading Synopsis]
|
||
```
|
||
std::uint64_t&
|
||
get_uint64();
|
||
```
|
||
|
||
[heading Description]
|
||
This is the fastest way to access the underlying representation when the kind is known in advance.
|
||
|
||
[heading Preconditions]
|
||
|
||
```
|
||
this->is_uint64()
|
||
```
|
||
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::get_uint64 (2 of 2 overloads)]
|
||
|
||
Return the underlying `std::uint64_t`, without checking.
|
||
[heading Synopsis]
|
||
```
|
||
std::uint64_t
|
||
get_uint64() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This is the fastest way to access the underlying representation when the kind is known in advance.
|
||
|
||
[heading Preconditions]
|
||
|
||
```
|
||
this->is_uint64()
|
||
```
|
||
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:get_double value::get_double]
|
||
[indexterm2 get_double..value]
|
||
|
||
|
||
Return a reference to the underlying `double`, without checking.
|
||
```
|
||
double&
|
||
``[link json.ref.boost__json__value.get_double.overload1 get_double]``();
|
||
``[''''»''' [link json.ref.boost__json__value.get_double.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Return the underlying `double`, without checking.
|
||
```
|
||
double
|
||
``[link json.ref.boost__json__value.get_double.overload2 get_double]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.get_double.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::get_double (1 of 2 overloads)]
|
||
|
||
Return a reference to the underlying `double`, without checking.
|
||
[heading Synopsis]
|
||
```
|
||
double&
|
||
get_double();
|
||
```
|
||
|
||
[heading Description]
|
||
This is the fastest way to access the underlying representation when the kind is known in advance.
|
||
|
||
[heading Preconditions]
|
||
|
||
```
|
||
this->is_double()
|
||
```
|
||
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::get_double (2 of 2 overloads)]
|
||
|
||
Return the underlying `double`, without checking.
|
||
[heading Synopsis]
|
||
```
|
||
double
|
||
get_double() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This is the fastest way to access the underlying representation when the kind is known in advance.
|
||
|
||
[heading Preconditions]
|
||
|
||
```
|
||
this->is_double()
|
||
```
|
||
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:get_bool value::get_bool]
|
||
[indexterm2 get_bool..value]
|
||
|
||
|
||
Return a reference to the underlying `bool`, without checking.
|
||
```
|
||
bool&
|
||
``[link json.ref.boost__json__value.get_bool.overload1 get_bool]``();
|
||
``[''''»''' [link json.ref.boost__json__value.get_bool.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Return the underlying `bool`, without checking.
|
||
```
|
||
bool
|
||
``[link json.ref.boost__json__value.get_bool.overload2 get_bool]``() const;
|
||
``[''''»''' [link json.ref.boost__json__value.get_bool.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::get_bool (1 of 2 overloads)]
|
||
|
||
Return a reference to the underlying `bool`, without checking.
|
||
[heading Synopsis]
|
||
```
|
||
bool&
|
||
get_bool();
|
||
```
|
||
|
||
[heading Description]
|
||
This is the fastest way to access the underlying representation when the kind is known in advance.
|
||
|
||
[heading Preconditions]
|
||
|
||
```
|
||
this->is_bool()
|
||
```
|
||
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::get_bool (2 of 2 overloads)]
|
||
|
||
Return the underlying `bool`, without checking.
|
||
[heading Synopsis]
|
||
```
|
||
bool
|
||
get_bool() const;
|
||
```
|
||
|
||
[heading Description]
|
||
This is the fastest way to access the underlying representation when the kind is known in advance.
|
||
|
||
[heading Preconditions]
|
||
|
||
```
|
||
this->is_bool()
|
||
```
|
||
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:at value::at]
|
||
[indexterm2 at..value]
|
||
|
||
|
||
Access an element, with bounds checking.
|
||
```
|
||
value const&
|
||
``[link json.ref.boost__json__value.at.overload1 at]``(
|
||
string_view key) const;
|
||
``[''''»''' [link json.ref.boost__json__value.at.overload1 `more...`]]``
|
||
|
||
value const&
|
||
``[link json.ref.boost__json__value.at.overload2 at]``(
|
||
std::size_t pos) const;
|
||
``[''''»''' [link json.ref.boost__json__value.at.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value::at (1 of 2 overloads)]
|
||
|
||
Access an element, with bounds checking.
|
||
[heading Synopsis]
|
||
```
|
||
value const&
|
||
at(
|
||
string_view key) const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function is used to access elements of the underlying object, or throw an exception if the value is not an object.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`key`
|
||
]
|
||
[
|
||
The key of the element to find.
|
||
]
|
||
]
|
||
]
|
||
[heading Return Value]
|
||
`this->as_object().at( key )`.
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value::at (2 of 2 overloads)]
|
||
|
||
Access an element, with bounds checking.
|
||
[heading Synopsis]
|
||
```
|
||
value const&
|
||
at(
|
||
std::size_t pos) const;
|
||
```
|
||
|
||
[heading Description]
|
||
This function is used to access elements of the underlying array, or throw an exception if the value is not an array.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`pos`
|
||
]
|
||
[
|
||
A zero-based array index.
|
||
]
|
||
]
|
||
]
|
||
[heading Return Value]
|
||
`this->as_array().at( pos )`.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:operator_eq__eq_ value::operator==]
|
||
[indexterm2 operator==..value]
|
||
|
||
|
||
Return `true` if two values are equal.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/value.hpp]
|
||
|
||
```
|
||
friend bool
|
||
operator==(
|
||
value const& lhs,
|
||
value const& rhs);
|
||
```
|
||
|
||
[heading Description]
|
||
Two values are equal when they are the same kind and their referenced values are equal, or when they are both integral types and their integral representations are equal.
|
||
|
||
[heading Complexity]
|
||
Constant or linear in the size of the array, object, or string.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:operator_not__eq_ value::operator!=]
|
||
[indexterm2 operator!=..value]
|
||
|
||
|
||
Return `true` if two values are not equal.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/value.hpp]
|
||
|
||
```
|
||
friend bool
|
||
operator!=(
|
||
value const& lhs,
|
||
value const& rhs);
|
||
```
|
||
|
||
[heading Description]
|
||
Two values are equal when they are the same kind and their referenced values are equal, or when they are both integral types and their integral representations are equal.
|
||
|
||
[heading Complexity]
|
||
Constant or linear in the size of the array, object, or string.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__value_from_tag value_from_tag]
|
||
|
||
Customization point tag.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/value_from.hpp]
|
||
|
||
```
|
||
struct value_from_tag
|
||
```
|
||
|
||
[heading Description]
|
||
This tag type is used by the function [link json.ref.boost__json__value_from `value_from`] to select overloads of `tag_invoke`.
|
||
|
||
[heading Remarks]
|
||
This type is empty; it has no members.
|
||
[heading See Also]
|
||
[link json.ref.boost__json__value_from `value_from`], [link json.ref.boost__json__value_to `value_to`], [link json.ref.boost__json__value_to_tag `value_to_tag`], [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1895r0.pdf tag_invoke: A general pattern for supporting customisable functions]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__value_ref value_ref]
|
||
|
||
The type used in initializer lists.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/value_ref.hpp]
|
||
|
||
```
|
||
class value_ref
|
||
```
|
||
|
||
[heading Member Functions]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__value_ref.value_ref value_ref] [role silver \[constructor\]]]
|
||
]
|
||
[Constructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
This type is used in initializer lists for lazy construction of and assignment to the container types [link json.ref.boost__json__value `value`], [link json.ref.boost__json__array `array`], and [link json.ref.boost__json__object `object`]. The two types of initializer lists used are:
|
||
|
||
* `std::initializer_list< value_ref >` for constructing or assigning a [link json.ref.boost__json__value `value`] or [link json.ref.boost__json__array `array`], and
|
||
|
||
* `std::initializer_list< std::pair< string_view, value_ref > >` for constructing or assigning an [link json.ref.boost__json__object `object`].
|
||
|
||
A `value_ref` uses reference semantics. Creation of the actual container from the initializer list is lazily deferred until the list is used. This means that the [link json.ref.boost__json__memory_resource `memory_resource`] used to construct a container can be specified after the point where the initializer list is specified.
|
||
|
||
[heading Example]
|
||
|
||
This example demonstrates how a user-defined type containing a JSON value can be constructed from an initializer list:
|
||
|
||
```
|
||
class my_type
|
||
{
|
||
value jv_;
|
||
|
||
public:
|
||
my_type( std::initializer_list< value_ref > init )
|
||
: jv_(init)
|
||
{
|
||
}
|
||
};
|
||
```
|
||
|
||
|
||
[heading Remarks]
|
||
Never declare a variable of type `std::initializer_list` except in function parameter lists, otherwise the behavior may be undefined.
|
||
[heading See Also]
|
||
[link json.ref.boost__json__value `value`], [link json.ref.boost__json__array `array`], [link json.ref.boost__json__object `object`]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
[section:value_ref value_ref::value_ref]
|
||
[indexterm2 value_ref..value_ref]
|
||
|
||
|
||
Constructor.
|
||
```
|
||
``[link json.ref.boost__json__value_ref.value_ref.overload1 value_ref]``(
|
||
value_ref const&);
|
||
``[''''»''' [link json.ref.boost__json__value_ref.value_ref.overload1 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value_ref.value_ref.overload2 value_ref]``(
|
||
string_view s);
|
||
``[''''»''' [link json.ref.boost__json__value_ref.value_ref.overload2 `more...`]]``
|
||
|
||
template<
|
||
class T>
|
||
``[link json.ref.boost__json__value_ref.value_ref.overload3 value_ref]``(
|
||
T const& t);
|
||
``[''''»''' [link json.ref.boost__json__value_ref.value_ref.overload3 `more...`]]``
|
||
|
||
template<
|
||
class T>
|
||
``[link json.ref.boost__json__value_ref.value_ref.overload4 value_ref]``(
|
||
T&& t);
|
||
``[''''»''' [link json.ref.boost__json__value_ref.value_ref.overload4 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value_ref.value_ref.overload5 value_ref]``(
|
||
bool b);
|
||
``[''''»''' [link json.ref.boost__json__value_ref.value_ref.overload5 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value_ref.value_ref.overload6 value_ref]``(
|
||
std::initializer_list< value_ref > t);
|
||
``[''''»''' [link json.ref.boost__json__value_ref.value_ref.overload6 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value_ref.value_ref.overload7 value_ref]``(
|
||
signed char t);
|
||
``[''''»''' [link json.ref.boost__json__value_ref.value_ref.overload7 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value_ref.value_ref.overload8 value_ref]``(
|
||
short t);
|
||
``[''''»''' [link json.ref.boost__json__value_ref.value_ref.overload8 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value_ref.value_ref.overload9 value_ref]``(
|
||
int t);
|
||
``[''''»''' [link json.ref.boost__json__value_ref.value_ref.overload9 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value_ref.value_ref.overload10 value_ref]``(
|
||
long t);
|
||
``[''''»''' [link json.ref.boost__json__value_ref.value_ref.overload10 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value_ref.value_ref.overload11 value_ref]``(
|
||
long long t);
|
||
``[''''»''' [link json.ref.boost__json__value_ref.value_ref.overload11 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value_ref.value_ref.overload12 value_ref]``(
|
||
unsigned char t);
|
||
``[''''»''' [link json.ref.boost__json__value_ref.value_ref.overload12 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value_ref.value_ref.overload13 value_ref]``(
|
||
unsigned short t);
|
||
``[''''»''' [link json.ref.boost__json__value_ref.value_ref.overload13 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value_ref.value_ref.overload14 value_ref]``(
|
||
unsigned int t);
|
||
``[''''»''' [link json.ref.boost__json__value_ref.value_ref.overload14 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value_ref.value_ref.overload15 value_ref]``(
|
||
unsigned long t);
|
||
``[''''»''' [link json.ref.boost__json__value_ref.value_ref.overload15 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value_ref.value_ref.overload16 value_ref]``(
|
||
unsigned long long t);
|
||
``[''''»''' [link json.ref.boost__json__value_ref.value_ref.overload16 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value_ref.value_ref.overload17 value_ref]``(
|
||
float t);
|
||
``[''''»''' [link json.ref.boost__json__value_ref.value_ref.overload17 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value_ref.value_ref.overload18 value_ref]``(
|
||
double t);
|
||
``[''''»''' [link json.ref.boost__json__value_ref.value_ref.overload18 `more...`]]``
|
||
|
||
``[link json.ref.boost__json__value_ref.value_ref.overload19 value_ref]``(
|
||
std::nullptr_t);
|
||
``[''''»''' [link json.ref.boost__json__value_ref.value_ref.overload19 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value_ref::value_ref (1 of 19 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value_ref(
|
||
value_ref const&);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value_ref::value_ref (2 of 19 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value_ref(
|
||
string_view s);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 value_ref::value_ref (3 of 19 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class T>
|
||
value_ref(
|
||
T const& t);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 value_ref::value_ref (4 of 19 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
template<
|
||
class T>
|
||
value_ref(
|
||
T&& t);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload5 value_ref::value_ref (5 of 19 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value_ref(
|
||
bool b);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload6 value_ref::value_ref (6 of 19 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value_ref(
|
||
std::initializer_list< value_ref > t);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload7 value_ref::value_ref (7 of 19 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value_ref(
|
||
signed char t);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload8 value_ref::value_ref (8 of 19 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value_ref(
|
||
short t);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload9 value_ref::value_ref (9 of 19 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value_ref(
|
||
int t);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload10 value_ref::value_ref (10 of 19 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value_ref(
|
||
long t);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload11 value_ref::value_ref (11 of 19 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value_ref(
|
||
long long t);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload12 value_ref::value_ref (12 of 19 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value_ref(
|
||
unsigned char t);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload13 value_ref::value_ref (13 of 19 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value_ref(
|
||
unsigned short t);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload14 value_ref::value_ref (14 of 19 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value_ref(
|
||
unsigned int t);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload15 value_ref::value_ref (15 of 19 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value_ref(
|
||
unsigned long t);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload16 value_ref::value_ref (16 of 19 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value_ref(
|
||
unsigned long long t);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload17 value_ref::value_ref (17 of 19 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value_ref(
|
||
float t);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload18 value_ref::value_ref (18 of 19 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value_ref(
|
||
double t);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload19 value_ref::value_ref (19 of 19 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value_ref(
|
||
std::nullptr_t);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__value_stack value_stack]
|
||
|
||
A stack of [link json.ref.boost__json__value `value`] elements, for building a document.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/value_stack.hpp]
|
||
|
||
```
|
||
class value_stack
|
||
```
|
||
|
||
[heading Member Functions]
|
||
[table [[Name][Description]]
|
||
[
|
||
[[*[link json.ref.boost__json__value_stack.operator_eq_ operator=]]
|
||
]
|
||
[Copy assignment (deleted)
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value_stack.push_array push_array]]
|
||
]
|
||
[Push an array formed by popping `n` values from the stack.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value_stack.push_bool push_bool]]
|
||
]
|
||
[Push a `bool` onto the stack.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value_stack.push_chars push_chars]]
|
||
]
|
||
[Push part of a key or string onto the stack.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value_stack.push_double push_double]]
|
||
]
|
||
[Push a number onto the stack.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value_stack.push_int64 push_int64]]
|
||
]
|
||
[Push a number onto the stack.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value_stack.push_key push_key]]
|
||
]
|
||
[Push a key onto the stack.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value_stack.push_null push_null]]
|
||
]
|
||
[Push a null onto the stack.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value_stack.push_object push_object]]
|
||
]
|
||
[Push an object formed by popping `n` key/value pairs from the stack.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value_stack.push_string push_string]]
|
||
]
|
||
[Place a string value onto the stack.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value_stack.push_uint64 push_uint64]]
|
||
]
|
||
[Push a number onto the stack.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value_stack.release release]]
|
||
]
|
||
[Return the top-level [link json.ref.boost__json__value `value`].
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value_stack.reset reset]]
|
||
]
|
||
[Prepare to build a new document.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value_stack.value_stack value_stack] [role silver \[constructor\]]]
|
||
]
|
||
[Copy constructor (deleted) [br][role silver —][br]Constructor.
|
||
]
|
||
]
|
||
[
|
||
[[*[link json.ref.boost__json__value_stack._value_stack ~value_stack] [role silver \[destructor\]]]
|
||
]
|
||
[Destructor.
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
This stack of [link json.ref.boost__json__value `value`] allows iterative construction of a JSON document in memory. The implementation uses temporary internal storage to buffer elements so that arrays, objects, and strings in the document are constructed using a single memory allocation. This improves performance and makes efficient use of the [link json.ref.boost__json__memory_resource `memory_resource`] used to create the resulting [link json.ref.boost__json__value `value`].
|
||
Temporary storage used by the implementation initially comes from an optional memory buffer owned by the caller. If that storage is exhausted, then memory is obtained dynamically from the [link json.ref.boost__json__memory_resource `memory_resource`] provided on construction.
|
||
|
||
[heading Usage]
|
||
|
||
Construct the stack with an optional initial temporary buffer, and a [link json.ref.boost__json__storage_ptr `storage_ptr`] to use for more storage when the initial buffer is exhausted. Then to build a [link json.ref.boost__json__value `value`], first call [link json.ref.boost__json__value_stack.reset `reset`] and optionally specify the [link json.ref.boost__json__memory_resource `memory_resource`] which will be used for the value. Then push elements onto the stack by calling the corresponding functions. After the document has been fully created, call [link json.ref.boost__json__value_stack.release `release`] to acquire ownership of the top-level [link json.ref.boost__json__value `value`].
|
||
|
||
[heading Performance]
|
||
|
||
The initial buffer and any dynamically allocated temporary buffers are retained until the stack is destroyed. This improves performance when using a single stack instance to produce multiple values.
|
||
|
||
[heading Example]
|
||
|
||
The following code constructs a [link json.ref.boost__json__value `value`] which when serialized produces a JSON object with three elements. It uses a local buffer for the temporary storage, and a separate local buffer for the storage of the resulting value. No memory is dynamically allocated; this shows how to construct a value without using the heap.
|
||
|
||
```
|
||
// This example builds a json::value without any dynamic memory allocations:
|
||
|
||
// Construct the value stack using a local buffer
|
||
unsigned char temp\[4096\];
|
||
value_stack st( storage_ptr(), temp, sizeof(temp) );
|
||
|
||
// Create a static resource with a local initial buffer
|
||
unsigned char buf\[4096\];
|
||
static_resource mr( buf, sizeof(buf) );
|
||
|
||
// All values on the stack will use `mr`
|
||
st.reset(&mr);
|
||
|
||
// Push the key/value pair "a":1.
|
||
st.push_key("a");
|
||
st.push_int64(1);
|
||
|
||
// Push "b":null
|
||
st.push_key("b");
|
||
st.push_null();
|
||
|
||
// Push "c":"hello"
|
||
st.push_key("c");
|
||
st.push_string("hello");
|
||
|
||
// Pop the three key/value pairs and push an object with those three values.
|
||
st.push_object(3);
|
||
|
||
// Pop the object from the stack and take ownership.
|
||
value jv = st.release();
|
||
|
||
assert( serialize(jv) == "{\"a\":1,\"b\":null,\"c\":\"hello\"}" );
|
||
|
||
// At this point we could re-use the stack by calling reset
|
||
```
|
||
|
||
|
||
[heading Thread Safety]
|
||
|
||
Distinct instances may be accessed concurrently. Non-const member functions of a shared instance may not be called concurrently with any other member functions of that instance.
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
[section:value_stack value_stack::value_stack]
|
||
[indexterm2 value_stack..value_stack]
|
||
|
||
|
||
Copy constructor (deleted)
|
||
```
|
||
``[link json.ref.boost__json__value_stack.value_stack.overload1 value_stack]``(
|
||
value_stack const&);
|
||
``[''''»''' [link json.ref.boost__json__value_stack.value_stack.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Constructor.
|
||
```
|
||
``[link json.ref.boost__json__value_stack.value_stack.overload2 value_stack]``(
|
||
storage_ptr sp = {},
|
||
unsigned char* temp_buffer = nullptr,
|
||
std::size_t temp_size = 0);
|
||
``[''''»''' [link json.ref.boost__json__value_stack.value_stack.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 value_stack::value_stack (1 of 2 overloads)]
|
||
|
||
Copy constructor (deleted)
|
||
[heading Synopsis]
|
||
```
|
||
value_stack(
|
||
value_stack const&);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 value_stack::value_stack (2 of 2 overloads)]
|
||
|
||
Constructor.
|
||
[heading Synopsis]
|
||
```
|
||
value_stack(
|
||
storage_ptr sp = {},
|
||
unsigned char* temp_buffer = nullptr,
|
||
std::size_t temp_size = 0);
|
||
```
|
||
|
||
[heading Description]
|
||
Constructs an empty stack. Before any [link json.ref.boost__json__value `value`] can be built, the function [link json.ref.boost__json__value_stack.reset `reset`] must be called.
|
||
The `sp` parameter is only used to allocate intermediate storage; it will not be used for the [link json.ref.boost__json__value `value`] returned by [link json.ref.boost__json__value_stack.release `release`].
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use for intermediate storage allocations. If this argument is omitted, the default memory resource is used.
|
||
]
|
||
]
|
||
[
|
||
[`temp_buffer`
|
||
]
|
||
[
|
||
A pointer to a caller-owned buffer which will be used to store temporary data used while building the value. If this pointer is null, the builder will use the storage pointer to allocate temporary data.
|
||
]
|
||
]
|
||
[
|
||
[`temp_size`
|
||
]
|
||
[
|
||
The number of valid bytes of storage pointed to by `temp_buffer`.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:operator_eq_ value_stack::operator=]
|
||
[indexterm2 operator=..value_stack]
|
||
|
||
|
||
Copy assignment (deleted)
|
||
[heading Synopsis]
|
||
```
|
||
value_stack&
|
||
operator=(
|
||
value_stack const&);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[endsect]
|
||
|
||
[section:_value_stack value_stack::~value_stack]
|
||
[indexterm2 ~value_stack..value_stack]
|
||
|
||
|
||
Destructor.
|
||
[heading Synopsis]
|
||
```
|
||
~value_stack();
|
||
```
|
||
|
||
[heading Description]
|
||
All dynamically allocated memory and partial or complete elements is freed.
|
||
|
||
[heading Complexity]
|
||
Linear in the size of partial results.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
[endsect]
|
||
|
||
[section:reset value_stack::reset]
|
||
[indexterm2 reset..value_stack]
|
||
|
||
|
||
Prepare to build a new document.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
reset(
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
This function must be called before constructing a new top-level [link json.ref.boost__json__value `value`]. Any previously existing partial or complete elements are destroyed, but internal dynamically allocated memory is preserved which may be reused to build new values.
|
||
|
||
[heading Exception Safety]
|
||
|
||
No-throw guarantee.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A pointer to the [link json.ref.boost__json__memory_resource `memory_resource`] to use for top-level [link json.ref.boost__json__value `value`] and all child values. The stack will acquire shared ownership of the memory resource until [link json.ref.boost__json__value_stack.release `release`] or [link json.ref.boost__json__value_stack.reset `reset`] is called, or when the stack is destroyed.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:release value_stack::release]
|
||
[indexterm2 release..value_stack]
|
||
|
||
|
||
Return the top-level [link json.ref.boost__json__value `value`].
|
||
[heading Synopsis]
|
||
```
|
||
value
|
||
release();
|
||
```
|
||
|
||
[heading Description]
|
||
This function transfers ownership of the constructed top-level value to the caller. The behavior is undefined if there is not a single, top-level element.
|
||
|
||
[heading Exception Safety]
|
||
|
||
No-throw guarantee.
|
||
|
||
[heading Return Value]
|
||
A [*value] holding the result. Ownership of this value is transferred to the caller. Ownership of the memory resource used in the last call to [link json.ref.boost__json__value_stack.reset `reset`] is released.
|
||
|
||
[endsect]
|
||
|
||
[section:push_array value_stack::push_array]
|
||
[indexterm2 push_array..value_stack]
|
||
|
||
|
||
Push an array formed by popping `n` values from the stack.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
push_array(
|
||
std::size_t n);
|
||
```
|
||
|
||
[heading Description]
|
||
This function pushes an [link json.ref.boost__json__array `array`] value onto the stack. The array is formed by first popping the top `n` values from the stack. If the stack contains fewer than `n` values, or if any of the top `n` values on the stack is a key, the behavior is undefined.
|
||
|
||
[heading Example]
|
||
|
||
The following statements produce an array with the contents 1, 2, 3:
|
||
|
||
```
|
||
value_stack st;
|
||
|
||
// reset must be called first or else the behavior is undefined
|
||
st.reset();
|
||
|
||
// Place three values on the stack
|
||
st.push_int64( 1 );
|
||
st.push_int64( 2 );
|
||
st.push_int64( 3 );
|
||
|
||
// Remove the 3 values, and push an array with those 3 elements on the stack
|
||
st.push_array( 3 );
|
||
|
||
// Pop the object from the stack and take ownership.
|
||
value jv = st.release();
|
||
|
||
assert( serialize(jv) == "\[1,2,3\]" );
|
||
|
||
// At this point, reset must be called again to use the stack
|
||
```
|
||
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`n`
|
||
]
|
||
[
|
||
The number of values to pop from the top of the stack to form the array.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:push_object value_stack::push_object]
|
||
[indexterm2 push_object..value_stack]
|
||
|
||
|
||
Push an object formed by popping `n` key/value pairs from the stack.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
push_object(
|
||
std::size_t n);
|
||
```
|
||
|
||
[heading Description]
|
||
This function pushes an [link json.ref.boost__json__object `object`] value onto the stack. The object is formed by first popping the top `n` key/value pairs from the stack. If the stack contains fewer than `n` key/value pairs, or if any of the top `n` key/value pairs on the stack does not consist of exactly one key followed by one value, the behavior is undefined.
|
||
|
||
[heading Remarks]
|
||
|
||
A key/value pair is formed by pushing a key, and then pushing a value.
|
||
|
||
[heading Example]
|
||
|
||
The following code creates an object on the stack with a single element, where key is "x" and value is true:
|
||
|
||
```
|
||
value_stack st;
|
||
|
||
// reset must be called first or else the behavior is undefined
|
||
st.reset();
|
||
|
||
// Place a key/value pair onto the stack
|
||
st.push_key( "x" );
|
||
st.push_bool( true );
|
||
|
||
// Replace the key/value pair with an object containing a single element
|
||
st.push_object( 1 );
|
||
|
||
// Pop the object from the stack and take ownership.
|
||
value jv = st.release();
|
||
|
||
assert( serialize(jv) == "{\"x\",true}" );
|
||
|
||
// At this point, reset must be called again to use the stack
|
||
```
|
||
|
||
|
||
[heading Duplicate Keys]
|
||
|
||
If there are object elements with duplicate keys; that is, if multiple elements in an object have keys that compare equal, only the last equivalent element will be inserted.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`n`
|
||
]
|
||
[
|
||
The number of key/value pairs to pop from the top of the stack to form the array.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:push_chars value_stack::push_chars]
|
||
[indexterm2 push_chars..value_stack]
|
||
|
||
|
||
Push part of a key or string onto the stack.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
push_chars(
|
||
string_view s);
|
||
```
|
||
|
||
[heading Description]
|
||
This function pushes the characters in `s` onto the stack, appending to any existing characters or creating new characters as needed. Once a string part is placed onto the stack, the only valid stack operations are:
|
||
|
||
* [link json.ref.boost__json__value_stack.push_chars `push_chars`] to append additional characters to the key or string being built,
|
||
|
||
* [link json.ref.boost__json__value_stack.push_key `push_key`] or [link json.ref.boost__json__value_stack.push_string `push_string`] to finish building the key or string and place the value onto the stack.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The characters to append. This may be empty.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:push_key value_stack::push_key]
|
||
[indexterm2 push_key..value_stack]
|
||
|
||
|
||
Push a key onto the stack.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
push_key(
|
||
string_view s);
|
||
```
|
||
|
||
[heading Description]
|
||
This function notionally removes all the characters currently on the stack, then pushes a [link json.ref.boost__json__value `value`] containing a key onto the stack formed by appending `s` to the removed characters.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The characters to append. This may be empty.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:push_string value_stack::push_string]
|
||
[indexterm2 push_string..value_stack]
|
||
|
||
|
||
Place a string value onto the stack.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
push_string(
|
||
string_view s);
|
||
```
|
||
|
||
[heading Description]
|
||
This function notionally removes all the characters currently on the stack, then pushes a [link json.ref.boost__json__value `value`] containing a [link json.ref.boost__json__string `string`] onto the stack formed by appending `s` to the removed characters.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The characters to append. This may be empty.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:push_int64 value_stack::push_int64]
|
||
[indexterm2 push_int64..value_stack]
|
||
|
||
|
||
Push a number onto the stack.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
push_int64(
|
||
int64_t i);
|
||
```
|
||
|
||
[heading Description]
|
||
This function pushes a number value onto the stack.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`i`
|
||
]
|
||
[
|
||
The number to insert.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:push_uint64 value_stack::push_uint64]
|
||
[indexterm2 push_uint64..value_stack]
|
||
|
||
|
||
Push a number onto the stack.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
push_uint64(
|
||
uint64_t u);
|
||
```
|
||
|
||
[heading Description]
|
||
This function pushes a number value onto the stack.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`u`
|
||
]
|
||
[
|
||
The number to insert.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:push_double value_stack::push_double]
|
||
[indexterm2 push_double..value_stack]
|
||
|
||
|
||
Push a number onto the stack.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
push_double(
|
||
double d);
|
||
```
|
||
|
||
[heading Description]
|
||
This function pushes a number value onto the stack.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`d`
|
||
]
|
||
[
|
||
The number to insert.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:push_bool value_stack::push_bool]
|
||
[indexterm2 push_bool..value_stack]
|
||
|
||
|
||
Push a `bool` onto the stack.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
push_bool(
|
||
bool b);
|
||
```
|
||
|
||
[heading Description]
|
||
This function pushes a boolean value onto the stack.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`b`
|
||
]
|
||
[
|
||
The boolean to insert.
|
||
]
|
||
]
|
||
]
|
||
|
||
[endsect]
|
||
|
||
[section:push_null value_stack::push_null]
|
||
[indexterm2 push_null..value_stack]
|
||
|
||
|
||
Push a null onto the stack.
|
||
[heading Synopsis]
|
||
```
|
||
void
|
||
push_null();
|
||
```
|
||
|
||
[heading Description]
|
||
This function pushes a boolean value onto the stack.
|
||
|
||
[heading Exception Safety]
|
||
|
||
Basic guarantee. Calls to `memory_resource::allocate` may throw.
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__value_to_tag value_to_tag]
|
||
|
||
Customization point tag type.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/value_to.hpp]
|
||
|
||
```
|
||
template<
|
||
class T>
|
||
struct value_to_tag
|
||
```
|
||
|
||
[heading Description]
|
||
This tag type is used by the function [link json.ref.boost__json__value_to `value_to`] to select overloads of `tag_invoke`.
|
||
|
||
[heading Remarks]
|
||
This type is empty; it has no members.
|
||
[heading See Also]
|
||
[link json.ref.boost__json__value_from `value_from`], [link json.ref.boost__json__value_from_tag `value_from_tag`], [link json.ref.boost__json__value_to `value_to`], [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1895r0.pdf tag_invoke: A general pattern for supporting customisable functions]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__serialize serialize]
|
||
[indexterm1 serialize]
|
||
|
||
|
||
Return a string representing a serialized element.
|
||
```
|
||
std::string
|
||
``[link json.ref.boost__json__serialize.overload1 serialize]``(
|
||
value const& t);
|
||
``[''''»''' [link json.ref.boost__json__serialize.overload1 `more...`]]``
|
||
|
||
std::string
|
||
``[link json.ref.boost__json__serialize.overload2 serialize]``(
|
||
array const& t);
|
||
``[''''»''' [link json.ref.boost__json__serialize.overload2 `more...`]]``
|
||
|
||
std::string
|
||
``[link json.ref.boost__json__serialize.overload3 serialize]``(
|
||
object const& t);
|
||
``[''''»''' [link json.ref.boost__json__serialize.overload3 `more...`]]``
|
||
|
||
std::string
|
||
``[link json.ref.boost__json__serialize.overload4 serialize]``(
|
||
string const& t);
|
||
``[''''»''' [link json.ref.boost__json__serialize.overload4 `more...`]]``
|
||
|
||
std::string
|
||
``[link json.ref.boost__json__serialize.overload5 serialize]``(
|
||
string_view t);
|
||
``[''''»''' [link json.ref.boost__json__serialize.overload5 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 serialize (1 of 5 overloads)]
|
||
|
||
Return a string representing a serialized element.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/serialize.hpp]
|
||
|
||
```
|
||
std::string
|
||
serialize(
|
||
value const& t);
|
||
```
|
||
|
||
[heading Description]
|
||
This function serializes `t` as JSON and returns it as a `std::string`.
|
||
|
||
[heading Complexity]
|
||
Constant or linear in the size of `t`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to allocate may throw.
|
||
[heading Return Value]
|
||
The serialized string
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`t`
|
||
]
|
||
[
|
||
The value to serialize
|
||
]
|
||
]
|
||
]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 serialize (2 of 5 overloads)]
|
||
|
||
Return a string representing a serialized element.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/serialize.hpp]
|
||
|
||
```
|
||
std::string
|
||
serialize(
|
||
array const& t);
|
||
```
|
||
|
||
[heading Description]
|
||
This function serializes `t` as JSON and returns it as a `std::string`.
|
||
|
||
[heading Complexity]
|
||
Constant or linear in the size of `t`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to allocate may throw.
|
||
[heading Return Value]
|
||
The serialized string
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`t`
|
||
]
|
||
[
|
||
The value to serialize
|
||
]
|
||
]
|
||
]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 serialize (3 of 5 overloads)]
|
||
|
||
Return a string representing a serialized element.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/serialize.hpp]
|
||
|
||
```
|
||
std::string
|
||
serialize(
|
||
object const& t);
|
||
```
|
||
|
||
[heading Description]
|
||
This function serializes `t` as JSON and returns it as a `std::string`.
|
||
|
||
[heading Complexity]
|
||
Constant or linear in the size of `t`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to allocate may throw.
|
||
[heading Return Value]
|
||
The serialized string
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`t`
|
||
]
|
||
[
|
||
The value to serialize
|
||
]
|
||
]
|
||
]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 serialize (4 of 5 overloads)]
|
||
|
||
Return a string representing a serialized element.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/serialize.hpp]
|
||
|
||
```
|
||
std::string
|
||
serialize(
|
||
string const& t);
|
||
```
|
||
|
||
[heading Description]
|
||
This function serializes `t` as JSON and returns it as a `std::string`.
|
||
|
||
[heading Complexity]
|
||
Constant or linear in the size of `t`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to allocate may throw.
|
||
[heading Return Value]
|
||
The serialized string
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`t`
|
||
]
|
||
[
|
||
The value to serialize
|
||
]
|
||
]
|
||
]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:overload5 serialize (5 of 5 overloads)]
|
||
|
||
Return a string representing a serialized element.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/serialize.hpp]
|
||
|
||
```
|
||
std::string
|
||
serialize(
|
||
string_view t);
|
||
```
|
||
|
||
[heading Description]
|
||
This function serializes `t` as JSON and returns it as a `std::string`.
|
||
|
||
[heading Complexity]
|
||
Constant or linear in the size of `t`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to allocate may throw.
|
||
[heading Return Value]
|
||
The serialized string
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`t`
|
||
]
|
||
[
|
||
The value to serialize
|
||
]
|
||
]
|
||
]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__operator_lt__lt_ operator<<]
|
||
[indexterm1 operator<<]
|
||
|
||
|
||
Serialize an element to an output stream.
|
||
```
|
||
std::ostream&
|
||
``[link json.ref.boost__json__operator_lt__lt_.overload1 operator<<]``(
|
||
std::ostream& os,
|
||
value const& t);
|
||
``[''''»''' [link json.ref.boost__json__operator_lt__lt_.overload1 `more...`]]``
|
||
|
||
std::ostream&
|
||
``[link json.ref.boost__json__operator_lt__lt_.overload2 operator<<]``(
|
||
std::ostream& os,
|
||
array const& t);
|
||
``[''''»''' [link json.ref.boost__json__operator_lt__lt_.overload2 `more...`]]``
|
||
|
||
std::ostream&
|
||
``[link json.ref.boost__json__operator_lt__lt_.overload3 operator<<]``(
|
||
std::ostream& os,
|
||
object const& t);
|
||
``[''''»''' [link json.ref.boost__json__operator_lt__lt_.overload3 `more...`]]``
|
||
|
||
std::ostream&
|
||
``[link json.ref.boost__json__operator_lt__lt_.overload4 operator<<]``(
|
||
std::ostream& os,
|
||
string const& t);
|
||
``[''''»''' [link json.ref.boost__json__operator_lt__lt_.overload4 `more...`]]``
|
||
```
|
||
|
||
|
||
Format a kind to an output stream.
|
||
```
|
||
std::ostream&
|
||
``[link json.ref.boost__json__operator_lt__lt_.overload5 operator<<]``(
|
||
std::ostream& os,
|
||
kind k);
|
||
``[''''»''' [link json.ref.boost__json__operator_lt__lt_.overload5 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 operator<< (1 of 5 overloads)]
|
||
|
||
Serialize an element to an output stream.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/serialize.hpp]
|
||
|
||
```
|
||
std::ostream&
|
||
operator<<(
|
||
std::ostream& os,
|
||
value const& t);
|
||
```
|
||
|
||
[heading Description]
|
||
This function serializes the specified element as JSON into the output stream.
|
||
|
||
[heading Return Value]
|
||
`os`.
|
||
[heading Complexity]
|
||
Constant or linear in the size of `t`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`os`
|
||
]
|
||
[
|
||
The output stream to serialize to.
|
||
]
|
||
]
|
||
[
|
||
[`t`
|
||
]
|
||
[
|
||
The value to serialize
|
||
]
|
||
]
|
||
]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 operator<< (2 of 5 overloads)]
|
||
|
||
Serialize an element to an output stream.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/serialize.hpp]
|
||
|
||
```
|
||
std::ostream&
|
||
operator<<(
|
||
std::ostream& os,
|
||
array const& t);
|
||
```
|
||
|
||
[heading Description]
|
||
This function serializes the specified element as JSON into the output stream.
|
||
|
||
[heading Return Value]
|
||
`os`.
|
||
[heading Complexity]
|
||
Constant or linear in the size of `t`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`os`
|
||
]
|
||
[
|
||
The output stream to serialize to.
|
||
]
|
||
]
|
||
[
|
||
[`t`
|
||
]
|
||
[
|
||
The value to serialize
|
||
]
|
||
]
|
||
]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:overload3 operator<< (3 of 5 overloads)]
|
||
|
||
Serialize an element to an output stream.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/serialize.hpp]
|
||
|
||
```
|
||
std::ostream&
|
||
operator<<(
|
||
std::ostream& os,
|
||
object const& t);
|
||
```
|
||
|
||
[heading Description]
|
||
This function serializes the specified element as JSON into the output stream.
|
||
|
||
[heading Return Value]
|
||
`os`.
|
||
[heading Complexity]
|
||
Constant or linear in the size of `t`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`os`
|
||
]
|
||
[
|
||
The output stream to serialize to.
|
||
]
|
||
]
|
||
[
|
||
[`t`
|
||
]
|
||
[
|
||
The value to serialize
|
||
]
|
||
]
|
||
]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:overload4 operator<< (4 of 5 overloads)]
|
||
|
||
Serialize an element to an output stream.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/serialize.hpp]
|
||
|
||
```
|
||
std::ostream&
|
||
operator<<(
|
||
std::ostream& os,
|
||
string const& t);
|
||
```
|
||
|
||
[heading Description]
|
||
This function serializes the specified element as JSON into the output stream.
|
||
|
||
[heading Return Value]
|
||
`os`.
|
||
[heading Complexity]
|
||
Constant or linear in the size of `t`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`os`
|
||
]
|
||
[
|
||
The output stream to serialize to.
|
||
]
|
||
]
|
||
[
|
||
[`t`
|
||
]
|
||
[
|
||
The value to serialize
|
||
]
|
||
]
|
||
]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:overload5 operator<< (5 of 5 overloads)]
|
||
|
||
Format a kind to an output stream.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/kind.hpp]
|
||
|
||
```
|
||
std::ostream&
|
||
operator<<(
|
||
std::ostream& os,
|
||
kind k);
|
||
```
|
||
|
||
[heading Description]
|
||
This allows a [link json.ref.boost__json__kind `kind`] to be formatted as a string, typically for diagnostics.
|
||
|
||
[heading Return Value]
|
||
The output stream.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`os`
|
||
]
|
||
[
|
||
The output stream to format to.
|
||
]
|
||
]
|
||
[
|
||
[`k`
|
||
]
|
||
[
|
||
The kind to format.
|
||
]
|
||
]
|
||
]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__visit visit]
|
||
[indexterm1 visit]
|
||
|
||
|
||
Invoke a function object with the contents of a [link json.ref.boost__json__value `value`].
|
||
```
|
||
template<
|
||
class Visitor>
|
||
auto
|
||
``[link json.ref.boost__json__visit.overload1 visit]``(
|
||
Visitor&& v,
|
||
value& jv);
|
||
``[''''»''' [link json.ref.boost__json__visit.overload1 `more...`]]``
|
||
|
||
template<
|
||
class Visitor>
|
||
auto
|
||
``[link json.ref.boost__json__visit.overload2 visit]``(
|
||
Visitor&& v,
|
||
value const& jv);
|
||
``[''''»''' [link json.ref.boost__json__visit.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 visit (1 of 2 overloads)]
|
||
|
||
Invoke a function object with the contents of a [link json.ref.boost__json__value `value`].
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/visit.hpp]
|
||
|
||
```
|
||
template<
|
||
class Visitor>
|
||
auto
|
||
visit(
|
||
Visitor&& v,
|
||
value& jv);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[heading Return Value]
|
||
The value returned by Visitor.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`v`
|
||
]
|
||
[
|
||
The visitation function to invoke
|
||
]
|
||
]
|
||
[
|
||
[`jv`
|
||
]
|
||
[
|
||
The value to visit.
|
||
]
|
||
]
|
||
]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 visit (2 of 2 overloads)]
|
||
|
||
Invoke a function object with the contents of a [link json.ref.boost__json__value `value`].
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/visit.hpp]
|
||
|
||
```
|
||
template<
|
||
class Visitor>
|
||
auto
|
||
visit(
|
||
Visitor&& v,
|
||
value const& jv);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
[heading Return Value]
|
||
The value returned by Visitor.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`v`
|
||
]
|
||
[
|
||
The visitation function to invoke
|
||
]
|
||
]
|
||
[
|
||
[`jv`
|
||
]
|
||
[
|
||
The value to visit.
|
||
]
|
||
]
|
||
]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__error error]
|
||
[indexterm1 error]
|
||
|
||
|
||
Error codes returned by JSON operations.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/error.hpp]
|
||
|
||
```
|
||
enum error
|
||
```
|
||
|
||
[heading Values]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`syntax`
|
||
]
|
||
[
|
||
|
||
syntax error
|
||
|
||
]
|
||
]
|
||
[
|
||
[`extra_data`
|
||
]
|
||
[
|
||
|
||
extra data
|
||
|
||
]
|
||
]
|
||
[
|
||
[`incomplete`
|
||
]
|
||
[
|
||
|
||
incomplete JSON
|
||
|
||
]
|
||
]
|
||
[
|
||
[`exponent_overflow`
|
||
]
|
||
[
|
||
|
||
exponent too large
|
||
|
||
]
|
||
]
|
||
[
|
||
[`too_deep`
|
||
]
|
||
[
|
||
|
||
too deep
|
||
|
||
]
|
||
]
|
||
[
|
||
[`illegal_leading_surrogate`
|
||
]
|
||
[
|
||
|
||
illegal leading surrogate
|
||
|
||
]
|
||
]
|
||
[
|
||
[`illegal_trailing_surrogate`
|
||
]
|
||
[
|
||
|
||
illegal trailing surrogate
|
||
|
||
]
|
||
]
|
||
[
|
||
[`expected_hex_digit`
|
||
]
|
||
[
|
||
|
||
expected hex digit
|
||
|
||
]
|
||
]
|
||
[
|
||
[`expected_utf16_escape`
|
||
]
|
||
[
|
||
|
||
expected utf16 escape
|
||
|
||
]
|
||
]
|
||
[
|
||
[`object_too_large`
|
||
]
|
||
[
|
||
|
||
An object contains too many elements.
|
||
|
||
]
|
||
]
|
||
[
|
||
[`array_too_large`
|
||
]
|
||
[
|
||
|
||
An array contains too many elements.
|
||
|
||
]
|
||
]
|
||
[
|
||
[`key_too_large`
|
||
]
|
||
[
|
||
|
||
A key is too large.
|
||
|
||
]
|
||
]
|
||
[
|
||
[`string_too_large`
|
||
]
|
||
[
|
||
|
||
A string is too large.
|
||
|
||
]
|
||
]
|
||
[
|
||
[`exception`
|
||
]
|
||
[
|
||
|
||
The parser encountered an exception and must be reset.
|
||
|
||
]
|
||
]
|
||
[
|
||
[`not_number`
|
||
]
|
||
[
|
||
|
||
not a number
|
||
|
||
]
|
||
]
|
||
[
|
||
[`not_exact`
|
||
]
|
||
[
|
||
|
||
number cast is not exact
|
||
|
||
]
|
||
]
|
||
[
|
||
[`test_failure`
|
||
]
|
||
[
|
||
|
||
test failure
|
||
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__condition condition]
|
||
[indexterm1 condition]
|
||
|
||
|
||
Error conditions corresponding to JSON errors.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/error.hpp]
|
||
|
||
```
|
||
enum condition
|
||
```
|
||
|
||
[heading Values]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`parse_error`
|
||
]
|
||
[
|
||
|
||
A parser-related error.
|
||
|
||
]
|
||
]
|
||
[
|
||
[`assign_error`
|
||
]
|
||
[
|
||
|
||
An error on assignment to or from a JSON value.
|
||
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__kind kind]
|
||
[indexterm1 kind]
|
||
|
||
|
||
Constants for identifying the type of a value.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/kind.hpp]
|
||
|
||
```
|
||
enum kind
|
||
```
|
||
|
||
[heading Values]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`null`
|
||
]
|
||
[
|
||
|
||
The null value.
|
||
|
||
]
|
||
]
|
||
[
|
||
[`bool_`
|
||
]
|
||
[
|
||
|
||
A `bool`.
|
||
|
||
]
|
||
]
|
||
[
|
||
[`int64`
|
||
]
|
||
[
|
||
|
||
A `std::int64_t`
|
||
|
||
]
|
||
]
|
||
[
|
||
[`uint64`
|
||
]
|
||
[
|
||
|
||
A `std::uint64_t`
|
||
|
||
]
|
||
]
|
||
[
|
||
[`double_`
|
||
]
|
||
[
|
||
|
||
A `double`.
|
||
|
||
]
|
||
]
|
||
[
|
||
[`string`
|
||
]
|
||
[
|
||
|
||
A [link json.ref.boost__json__string `string`].
|
||
|
||
]
|
||
]
|
||
[
|
||
[`array`
|
||
]
|
||
[
|
||
|
||
An [link json.ref.boost__json__array `array`].
|
||
|
||
]
|
||
]
|
||
[
|
||
[`object`
|
||
]
|
||
[
|
||
|
||
An [link json.ref.boost__json__object `object`].
|
||
|
||
]
|
||
]
|
||
]
|
||
[heading Description]
|
||
These values are returned from [link json.ref.boost__json__value.kind `value::kind`]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__error_code error_code]
|
||
[indexterm1 error_code]
|
||
|
||
|
||
The type of error code used by the library.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/error.hpp]
|
||
|
||
```
|
||
using error_code = ``['see-below]``;
|
||
```
|
||
|
||
[heading Description]
|
||
This type alias is set depending on how the library is configured:
|
||
|
||
[heading Use with Boost]
|
||
|
||
If the macro `BOOST_JSON_STANDALONE` is not defined, this type will be an alias for `boost::system::error_code`. Compiling a program using the library will require Boost, and a compiler conforming to C++11 or later.
|
||
|
||
[heading Use without Boost]
|
||
|
||
If the macro `BOOST_JSON_STANDALONE` is defined, this type will be an alias for `std::error_code`. Compiling a program using the library will require only a compiler conforming to C++17 or later.
|
||
|
||
[heading See Also]
|
||
[@https://en.cppreference.com/w/cpp/error/error_code https://en.cppreference.com/w/cpp/error/error_code]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__error_category error_category]
|
||
[indexterm1 error_category]
|
||
|
||
|
||
The type of error category used by the library.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/error.hpp]
|
||
|
||
```
|
||
using error_category = ``['see-below]``;
|
||
```
|
||
|
||
[heading Description]
|
||
This type alias is set depending on how the library is configured:
|
||
|
||
[heading Use with Boost]
|
||
|
||
If the macro `BOOST_JSON_STANDALONE` is not defined, this type will be an alias for `boost::system::error_category`. Compiling a program using the library will require Boost, and a compiler conforming to C++11 or later.
|
||
|
||
[heading Use without Boost]
|
||
|
||
If the macro `BOOST_JSON_STANDALONE` is defined, this type will be an alias for `std::error_category`. Compiling a program using the library will require only a compiler conforming to C++17 or later.
|
||
|
||
[heading See Also]
|
||
[@https://en.cppreference.com/w/cpp/error/error_category https://en.cppreference.com/w/cpp/error/error_category]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__error_condition error_condition]
|
||
[indexterm1 error_condition]
|
||
|
||
|
||
The type of error condition used by the library.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/error.hpp]
|
||
|
||
```
|
||
using error_condition = ``['see-below]``;
|
||
```
|
||
|
||
[heading Description]
|
||
This type alias is set depending on how the library is configured:
|
||
|
||
[heading Use with Boost]
|
||
|
||
If the macro `BOOST_JSON_STANDALONE` is not defined, this type will be an alias for `boost::system::error_condition`. Compiling a program using the library will require Boost, and a compiler conforming to C++11 or later.
|
||
|
||
[heading Use without Boost]
|
||
|
||
If the macro `BOOST_JSON_STANDALONE` is defined, this type will be an alias for `std::error_condition`. Compiling a program using the library will require only a compiler conforming to C++17 or later.
|
||
|
||
[heading See Also]
|
||
[@https://en.cppreference.com/w/cpp/error/error_condition https://en.cppreference.com/w/cpp/error/error_condition]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__system_error system_error]
|
||
[indexterm1 system_error]
|
||
|
||
|
||
The type of system error thrown by the library.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/error.hpp]
|
||
|
||
```
|
||
using system_error = ``['see-below]``;
|
||
```
|
||
|
||
[heading Description]
|
||
This type alias is set depending on how the library is configured:
|
||
|
||
[heading Use with Boost]
|
||
|
||
If the macro `BOOST_JSON_STANDALONE` is not defined, this type will be an alias for `boost::system::system_error`. Compiling a program using the library will require Boost, and a compiler conforming to C++11 or later.
|
||
|
||
[heading Use without Boost]
|
||
|
||
If the macro `BOOST_JSON_STANDALONE` is defined, this type will be an alias for `std::system_error`. Compiling a program using the library will require only a compiler conforming to C++17 or later.
|
||
|
||
[heading See Also]
|
||
[@https://en.cppreference.com/w/cpp/error/system_error https://en.cppreference.com/w/cpp/error/system_error]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__string_view string_view]
|
||
[indexterm1 string_view]
|
||
|
||
|
||
The type of string view used by the library.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/string_view.hpp]
|
||
|
||
```
|
||
using string_view = ``['see-below]``;
|
||
```
|
||
|
||
[heading Description]
|
||
This type alias is set depending on how the library is configured:
|
||
|
||
[heading Use with Boost]
|
||
|
||
If the macro `BOOST_JSON_STANDALONE` is not defined, this type will be an alias for `boost::string_view`. Compiling a program using the library will require Boost, and a compiler conforming to C++11 or later.
|
||
|
||
[heading Use without Boost]
|
||
|
||
If the macro `BOOST_JSON_STANDALONE` is defined, this type will be an alias for `std::string_view`. Compiling a program using the library will require only a compiler conforming to C++17 or later.
|
||
|
||
[heading See Also]
|
||
[@https://en.cppreference.com/w/cpp/string/basic_string_view https://en.cppreference.com/w/cpp/string/basic_string_view]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__has_value_from has_value_from]
|
||
[indexterm1 has_value_from]
|
||
|
||
|
||
Determine if `T` can be converted to [link json.ref.boost__json__value `value`].
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/value_from.hpp]
|
||
|
||
```
|
||
template<
|
||
class T>
|
||
using has_value_from = ``['see-below]``;
|
||
```
|
||
|
||
[heading Description]
|
||
If `T` can be converted to [link json.ref.boost__json__value `value`] via a call to [link json.ref.boost__json__value_from `value_from`], the static data member `value` is defined as `true`. Otherwise, `value` is defined as `false`.
|
||
|
||
[heading See Also]
|
||
[link json.ref.boost__json__value_from `value_from`]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__has_value_to has_value_to]
|
||
[indexterm1 has_value_to]
|
||
|
||
|
||
Determine a [link json.ref.boost__json__value `value`] can be converted to `T`.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/value_to.hpp]
|
||
|
||
```
|
||
template<
|
||
class T>
|
||
using has_value_to = ``['see-below]``;
|
||
```
|
||
|
||
[heading Description]
|
||
If [link json.ref.boost__json__value `value`] can be converted to `T` via a call to [link json.ref.boost__json__value_to `value_to`], the static data member `value` is defined as `true`. Otherwise, `value` is defined as `false`.
|
||
|
||
[heading See Also]
|
||
[link json.ref.boost__json__value_to `value_to`]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__array_kind array_kind]
|
||
[indexterm1 array_kind]
|
||
|
||
|
||
A constant used to select a [link json.ref.boost__json__value `value`] constructor overload.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/kind.hpp]
|
||
|
||
```
|
||
constexpr array_kind_t array_kind;
|
||
```
|
||
|
||
[heading Description]
|
||
The library provides this constant to allow efficient construction of a [link json.ref.boost__json__value `value`] containing an empty [link json.ref.boost__json__array `array`].
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
storage_ptr sp;
|
||
value jv( array_kind, sp ); // sp is an optional parameter
|
||
```
|
||
|
||
[heading See Also]
|
||
[link json.ref.boost__json__array_kind_t `array_kind_t`]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__object_kind object_kind]
|
||
[indexterm1 object_kind]
|
||
|
||
|
||
A constant used to select a [link json.ref.boost__json__value `value`] constructor overload.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/kind.hpp]
|
||
|
||
```
|
||
constexpr object_kind_t object_kind;
|
||
```
|
||
|
||
[heading Description]
|
||
The library provides this constant to allow efficient construction of a [link json.ref.boost__json__value `value`] containing an empty [link json.ref.boost__json__object `object`].
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
storage_ptr sp;
|
||
value jv( object_kind, sp ); // sp is an optional parameter
|
||
```
|
||
|
||
[heading See Also]
|
||
[link json.ref.boost__json__object_kind_t `object_kind_t`]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__string_kind string_kind]
|
||
[indexterm1 string_kind]
|
||
|
||
|
||
A constant used to select a [link json.ref.boost__json__value `value`] constructor overload.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/kind.hpp]
|
||
|
||
```
|
||
constexpr string_kind_t string_kind;
|
||
```
|
||
|
||
[heading Description]
|
||
The library provides this constant to allow efficient construction of a [link json.ref.boost__json__value `value`] containing an empty [link json.ref.boost__json__string `string`].
|
||
|
||
[heading Example]
|
||
|
||
```
|
||
storage_ptr sp;
|
||
value jv( string_kind, sp ); // sp is an optional parameter
|
||
```
|
||
|
||
[heading See Also]
|
||
[link json.ref.boost__json__string_kind_t `string_kind_t`]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__generic_category generic_category]
|
||
[indexterm1 generic_category]
|
||
|
||
|
||
Returns the generic error category used by the library.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/error.hpp]
|
||
|
||
```
|
||
error_category const&
|
||
generic_category();
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__to_string to_string]
|
||
[indexterm1 to_string]
|
||
|
||
|
||
Return a string representing a kind.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/kind.hpp]
|
||
|
||
```
|
||
string_view
|
||
to_string(
|
||
kind k);
|
||
```
|
||
|
||
[heading Description]
|
||
This provides a human-readable string representing a [link json.ref.boost__json__kind `kind`]. This may be useful for diagnostics.
|
||
|
||
[heading Return Value]
|
||
The string.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`k`
|
||
]
|
||
[
|
||
The kind.
|
||
]
|
||
]
|
||
]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__get_null_resource get_null_resource]
|
||
[indexterm1 get_null_resource]
|
||
|
||
|
||
Return a pointer to the null resource.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/null_resource.hpp]
|
||
|
||
```
|
||
memory_resource*
|
||
get_null_resource();
|
||
```
|
||
|
||
[heading Description]
|
||
This memory resource always throws the exception `std::bad_alloc` in calls to `allocate`.
|
||
|
||
[heading Complexity]
|
||
Constant.
|
||
[heading Exception Safety]
|
||
No-throw guarantee.
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__parse parse]
|
||
[indexterm1 parse]
|
||
|
||
|
||
Return parsed JSON as a [link json.ref.boost__json__value `value`].
|
||
```
|
||
value
|
||
``[link json.ref.boost__json__parse.overload1 parse]``(
|
||
string_view s,
|
||
error_code& ec,
|
||
storage_ptr sp = {},
|
||
parse_options const& opt = {});
|
||
``[''''»''' [link json.ref.boost__json__parse.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Parse a string of JSON into a [link json.ref.boost__json__value `value`].
|
||
```
|
||
value
|
||
``[link json.ref.boost__json__parse.overload2 parse]``(
|
||
string_view s,
|
||
storage_ptr sp = {},
|
||
parse_options const& opt = {});
|
||
``[''''»''' [link json.ref.boost__json__parse.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 parse (1 of 2 overloads)]
|
||
|
||
Return parsed JSON as a [link json.ref.boost__json__value `value`].
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/parse.hpp]
|
||
|
||
```
|
||
value
|
||
parse(
|
||
string_view s,
|
||
error_code& ec,
|
||
storage_ptr sp = {},
|
||
parse_options const& opt = {});
|
||
```
|
||
|
||
[heading Description]
|
||
This function parses an entire string in one step to produce a complete JSON object, returned as a [link json.ref.boost__json__value `value`]. If the buffer does not contain a complete serialized JSON, an error occurs. In this case the returned value will be null, using the default memory resource.
|
||
|
||
[heading Complexity]
|
||
Linear in `s.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Return Value]
|
||
A value representing the parsed JSON, or a null if any error occurred.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The string to parse.
|
||
]
|
||
]
|
||
[
|
||
[`ec`
|
||
]
|
||
[
|
||
Set to the error, if any occurred.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
The memory resource that the new value and all of its elements will use. If this parameter is omitted, the default memory resource is used.
|
||
]
|
||
]
|
||
[
|
||
[`opt`
|
||
]
|
||
[
|
||
The options for the parser. If this parameter is omitted, the parser will accept only standard JSON.
|
||
]
|
||
]
|
||
]
|
||
[heading See Also]
|
||
[link json.ref.boost__json__parse_options `parse_options`], [link json.ref.boost__json__stream_parser `stream_parser`].
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 parse (2 of 2 overloads)]
|
||
|
||
Parse a string of JSON into a [link json.ref.boost__json__value `value`].
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/parse.hpp]
|
||
|
||
```
|
||
value
|
||
parse(
|
||
string_view s,
|
||
storage_ptr sp = {},
|
||
parse_options const& opt = {});
|
||
```
|
||
|
||
[heading Description]
|
||
This function parses an entire string in one step to produce a complete JSON object, returned as a [link json.ref.boost__json__value `value`]. If the buffer does not contain a complete serialized JSON, an exception is thrown.
|
||
|
||
[heading Complexity]
|
||
Linear in `s.size()`.
|
||
[heading Exception Safety]
|
||
Strong guarantee. Calls to `memory_resource::allocate` may throw.
|
||
[heading Return Value]
|
||
A value representing the parsed JSON upon success.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`s`
|
||
]
|
||
[
|
||
The string to parse.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
The memory resource that the new value and all of its elements will use. If this parameter is omitted, the default memory resource is used.
|
||
]
|
||
]
|
||
[
|
||
[`opt`
|
||
]
|
||
[
|
||
The options for the parser. If this parameter is omitted, the parser will accept only standard JSON.
|
||
]
|
||
]
|
||
]
|
||
[heading Exceptions]
|
||
[table [[Type][Thrown On]]
|
||
[
|
||
[`system_error`
|
||
]
|
||
[
|
||
Thrown on failure.
|
||
]
|
||
]
|
||
]
|
||
[heading See Also]
|
||
[link json.ref.boost__json__parse_options `parse_options`], [link json.ref.boost__json__stream_parser `stream_parser`].
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__pilfer pilfer]
|
||
[indexterm1 pilfer]
|
||
|
||
|
||
Indicate that an object `t` may be pilfered from.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/pilfer.hpp]
|
||
|
||
```
|
||
template<
|
||
class T>
|
||
auto
|
||
pilfer(
|
||
T&& t);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
A ['pilfer] operation is the construction of a new object of type `T` from an existing object `t`. After the construction, the only valid operation on the pilfered-from object is destruction. This permits optimizations beyond those available for a move-construction, as the pilfered-from object is not required to be in a "usable" state.
|
||
|
||
|
||
This is used similarly to `std::move`.
|
||
|
||
[heading Example]
|
||
|
||
A pilfer constructor accepts a single argument of type [link json.ref.boost__json__pilfered `pilfered`] and throws nothing:
|
||
|
||
```
|
||
struct T
|
||
{
|
||
T( pilfered<T> ) noexcept;
|
||
};
|
||
```
|
||
|
||
Pilfer construction is performed using [link json.ref.boost__json__pilfer `pilfer`] :
|
||
|
||
```
|
||
{
|
||
T t1; // default construction
|
||
T t2( pilfer( t1 ) ); // pilfer-construct from t1
|
||
|
||
// At this point, t1 may only be destroyed
|
||
}
|
||
```
|
||
|
||
|
||
[heading See Also]
|
||
[link json.ref.boost__json__pilfered `pilfered`], [link json.ref.boost__json__is_pilfer_constructible `is_pilfer_constructible`], [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0308r0.html Valueless Variants Considered Harmful]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__make_shared_resource make_shared_resource]
|
||
[indexterm1 make_shared_resource]
|
||
|
||
|
||
Return shared ownership of a new, dynamically allocated memory resource.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/storage_ptr.hpp]
|
||
|
||
```
|
||
template<
|
||
class T,
|
||
class... Args>
|
||
storage_ptr
|
||
make_shared_resource(
|
||
Args&&... args);
|
||
```
|
||
|
||
[heading Description]
|
||
This function dynamically allocates a new memory resource as if by `operator new` that uses shared ownership. The lifetime of the memory resource will be extended until the last [link json.ref.boost__json__storage_ptr `storage_ptr`] which points to it is destroyed.
|
||
|
||
[heading Mandates]
|
||
|
||
```
|
||
std::is_base_of< memory_resource, T >::value == true
|
||
```
|
||
|
||
[heading Complexity]
|
||
Same as `new T( std::forward<Args>(args)... )`.
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Template Parameters]
|
||
[table [[Type][Description]]
|
||
[
|
||
[`T`
|
||
]
|
||
[
|
||
The type of memory resource to create.
|
||
]
|
||
]
|
||
]
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`args`
|
||
]
|
||
[
|
||
Parameters forwarded to the constructor of `T`.
|
||
]
|
||
]
|
||
]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__operator_eq__eq_ operator==]
|
||
[indexterm1 operator==]
|
||
|
||
|
||
Return true if two storage pointers point to the same memory resource.
|
||
```
|
||
bool
|
||
``[link json.ref.boost__json__operator_eq__eq_.overload1 operator==]``(
|
||
storage_ptr const& lhs,
|
||
storage_ptr const& rhs);
|
||
``[''''»''' [link json.ref.boost__json__operator_eq__eq_.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Return true if lhs equals rhs.
|
||
```
|
||
bool
|
||
``[link json.ref.boost__json__operator_eq__eq_.overload2 operator==]``(
|
||
string const& lhs,
|
||
string const& rhs);
|
||
``[''''»''' [link json.ref.boost__json__operator_eq__eq_.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 operator== (1 of 2 overloads)]
|
||
|
||
Return true if two storage pointers point to the same memory resource.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/storage_ptr.hpp]
|
||
|
||
```
|
||
bool
|
||
operator==(
|
||
storage_ptr const& lhs,
|
||
storage_ptr const& rhs);
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns `true` if the [link json.ref.boost__json__memory_resource `memory_resource`] objects pointed to by `lhs` and `rhs` have the same address.
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 operator== (2 of 2 overloads)]
|
||
|
||
Return true if lhs equals rhs.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/string.hpp]
|
||
|
||
```
|
||
bool
|
||
operator==(
|
||
string const& lhs,
|
||
string const& rhs);
|
||
```
|
||
|
||
[heading Description]
|
||
A lexicographical comparison is used.
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__operator_not__eq_ operator!=]
|
||
[indexterm1 operator!=]
|
||
|
||
|
||
Return true if two storage pointers point to different memory resources.
|
||
```
|
||
bool
|
||
``[link json.ref.boost__json__operator_not__eq_.overload1 operator!=]``(
|
||
storage_ptr const& lhs,
|
||
storage_ptr const& rhs);
|
||
``[''''»''' [link json.ref.boost__json__operator_not__eq_.overload1 `more...`]]``
|
||
```
|
||
|
||
|
||
Return true if lhs does not equal rhs.
|
||
```
|
||
bool
|
||
``[link json.ref.boost__json__operator_not__eq_.overload2 operator!=]``(
|
||
string const& lhs,
|
||
string const& rhs);
|
||
``[''''»''' [link json.ref.boost__json__operator_not__eq_.overload2 `more...`]]``
|
||
```
|
||
|
||
[section:overload1 operator!= (1 of 2 overloads)]
|
||
|
||
Return true if two storage pointers point to different memory resources.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/storage_ptr.hpp]
|
||
|
||
```
|
||
bool
|
||
operator!=(
|
||
storage_ptr const& lhs,
|
||
storage_ptr const& rhs);
|
||
```
|
||
|
||
[heading Description]
|
||
This function returns `true` if the [link json.ref.boost__json__memory_resource `memory_resource`] objects pointed to by `lhs` and `rhs` have different addresses.
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:overload2 operator!= (2 of 2 overloads)]
|
||
|
||
Return true if lhs does not equal rhs.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/string.hpp]
|
||
|
||
```
|
||
bool
|
||
operator!=(
|
||
string const& lhs,
|
||
string const& rhs);
|
||
```
|
||
|
||
[heading Description]
|
||
A lexicographical comparison is used.
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__operator_lt_ operator<]
|
||
[indexterm1 operator<]
|
||
|
||
|
||
Return true if lhs is less than rhs.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/string.hpp]
|
||
|
||
```
|
||
bool
|
||
operator<(
|
||
string const& lhs,
|
||
string const& rhs);
|
||
```
|
||
|
||
[heading Description]
|
||
A lexicographical comparison is used.
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__operator_lt__eq_ operator<=]
|
||
[indexterm1 operator<=]
|
||
|
||
|
||
Return true if lhs is less than or equal to rhs.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/string.hpp]
|
||
|
||
```
|
||
bool
|
||
operator<=(
|
||
string const& lhs,
|
||
string const& rhs);
|
||
```
|
||
|
||
[heading Description]
|
||
A lexicographical comparison is used.
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__operator_gt__eq_ operator>=]
|
||
[indexterm1 operator>=]
|
||
|
||
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/string.hpp]
|
||
|
||
```
|
||
bool
|
||
operator>=(
|
||
string const& lhs,
|
||
string const& rhs);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__operator_gt_ operator>]
|
||
[indexterm1 operator>]
|
||
|
||
|
||
Return true if lhs is greater than rhs.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/string.hpp]
|
||
|
||
```
|
||
bool
|
||
operator>(
|
||
string const& lhs,
|
||
string const& rhs);
|
||
```
|
||
|
||
[heading Description]
|
||
A lexicographical comparison is used.
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__BOOST_STATIC_ASSERT BOOST_STATIC_ASSERT]
|
||
[indexterm1 BOOST_STATIC_ASSERT]
|
||
|
||
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/value.hpp]
|
||
|
||
```
|
||
BOOST_STATIC_ASSERT(
|
||
sizeof(value) = =24);
|
||
```
|
||
|
||
[heading Description]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__get get]
|
||
[indexterm1 get]
|
||
|
||
|
||
Tuple-like element access.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/value.hpp]
|
||
|
||
```
|
||
template<
|
||
std::size_t I,
|
||
class T>
|
||
``['see-below]``
|
||
get(
|
||
T&& kvp);
|
||
```
|
||
|
||
[heading Description]
|
||
This overload permits the key and value of a `key_value_pair` to be accessed by index. For example:
|
||
|
||
```
|
||
key_value_pair kvp("num", 42);
|
||
|
||
string_view key = get<0>(kvp);
|
||
value& jv = get<1>(kvp);
|
||
```
|
||
|
||
|
||
[heading Structured Bindings]
|
||
|
||
When using C++17 or greater, objects of type [link json.ref.boost__json__key_value_pair `key_value_pair`] may be used to initialize structured bindings:
|
||
|
||
```
|
||
key_value_pair kvp("num", 42);
|
||
|
||
auto& \[key, value\] = kvp;
|
||
```
|
||
|
||
Depending on the value of `I`, the return type will be:
|
||
|
||
* `string_view const` if `I == 0`, or
|
||
|
||
* `value&`, `value const&`, or `value&&` if `I == 1`.
|
||
|
||
Any other value for `I` is ill-formed.
|
||
|
||
[heading Template Parameters]
|
||
[table [[Type][Description]]
|
||
[
|
||
[`I`
|
||
]
|
||
[
|
||
The element index to access.
|
||
]
|
||
]
|
||
]
|
||
[heading Constraints]
|
||
|
||
`std::is_same_v< std::remove_cvref_t<T>, key_value_pair >`
|
||
|
||
[heading Return Value]
|
||
`kvp.key()` if `I == 0`, or `kvp.value()` if `I == 1`.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`kvp`
|
||
]
|
||
[
|
||
The [link json.ref.boost__json__key_value_pair `key_value_pair`] object to access.
|
||
]
|
||
]
|
||
]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__value_from value_from]
|
||
[indexterm1 value_from]
|
||
|
||
|
||
Convert an object of type `T` to [link json.ref.boost__json__value `value`].
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/value_from.hpp]
|
||
|
||
```
|
||
template<
|
||
class T>
|
||
value
|
||
value_from(
|
||
T&& t,
|
||
storage_ptr sp = {});
|
||
```
|
||
|
||
[heading Description]
|
||
This function attempts to convert an object of type `T` to [link json.ref.boost__json__value `value`] using
|
||
|
||
* one of [link json.ref.boost__json__value `value`]'s constructors,
|
||
|
||
* a library-provided generic conversion, or
|
||
|
||
* a user-provided overload of `tag_invoke`.
|
||
|
||
In all cases, the conversion is done by calling an overload of `tag_invoke` found by argument-dependent lookup. Its signature should be similar to:
|
||
|
||
```
|
||
void tag_invoke( value_from_tag, value&, T );
|
||
```
|
||
|
||
A [link json.ref.boost__json__value `value`] constructed with the [link json.ref.boost__json__storage_ptr `storage_ptr`] passed to [link json.ref.boost__json__value_from `value_from`] is passed as the second argument to ensure that the memory resource is correctly propagated.
|
||
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Template Parameters]
|
||
[table [[Type][Description]]
|
||
[
|
||
[`T`
|
||
]
|
||
[
|
||
The type of the object to convert.
|
||
]
|
||
]
|
||
]
|
||
[heading Return Value]
|
||
`t` converted to [link json.ref.boost__json__value `value`].
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`t`
|
||
]
|
||
[
|
||
The object to convert.
|
||
]
|
||
]
|
||
[
|
||
[`sp`
|
||
]
|
||
[
|
||
A storage pointer referring to the memory resource to use for the returned [link json.ref.boost__json__value `value`]. The default argument for this parameter is `{}`.
|
||
]
|
||
]
|
||
]
|
||
[heading See Also]
|
||
[link json.ref.boost__json__value_from_tag `value_from_tag`], [link json.ref.boost__json__value_to `value_to`], [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1895r0.pdf tag_invoke: A general pattern for supporting customisable functions]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|
||
|
||
[section:boost__json__value_to value_to]
|
||
[indexterm1 value_to]
|
||
|
||
|
||
Convert a [link json.ref.boost__json__value `value`] to an object of type `T`.
|
||
[heading Synopsis]
|
||
Defined in header [include_file boost/json/value_to.hpp]
|
||
|
||
```
|
||
template<
|
||
class T>
|
||
T
|
||
value_to(
|
||
const value& jv);
|
||
```
|
||
|
||
[heading Description]
|
||
This function attempts to convert a [link json.ref.boost__json__value `value`] to `T` using
|
||
|
||
* one of [link json.ref.boost__json__value `value`]'s accessors, or
|
||
|
||
* a library-provided generic conversion, or
|
||
|
||
* a user-provided overload of `tag_invoke`.
|
||
|
||
In all cases, the conversion is done by calling an overload of `tag_invoke` found by argument-dependent lookup. Its signature should be similar to:
|
||
|
||
```
|
||
T tag_invoke( value_to_tag<T>, value );
|
||
```
|
||
|
||
The object returned by the function call is returned by [link json.ref.boost__json__value_to `value_to`] as the result of the conversion.
|
||
|
||
[heading Constraints]
|
||
|
||
```
|
||
! std::is_reference< T >::value
|
||
```
|
||
|
||
[heading Exception Safety]
|
||
Strong guarantee.
|
||
[heading Template Parameters]
|
||
[table [[Type][Description]]
|
||
[
|
||
[`T`
|
||
]
|
||
[
|
||
The type to convert to.
|
||
]
|
||
]
|
||
]
|
||
[heading Return Value]
|
||
`jv` converted to `T`.
|
||
[heading Parameters]
|
||
[table [[Name][Description]]
|
||
[
|
||
[`jv`
|
||
]
|
||
[
|
||
The [link json.ref.boost__json__value `value`] to convert.
|
||
]
|
||
]
|
||
]
|
||
[heading See Also]
|
||
[link json.ref.boost__json__value_to_tag `value_to_tag`], [link json.ref.boost__json__value_from `value_from`], [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1895r0.pdf tag_invoke: A general pattern for supporting customisable functions]
|
||
|
||
Convenience header [include_file boost/json.hpp]
|
||
|
||
|
||
[endsect]
|