Skip to content

Commit

Permalink
allocators doc
Browse files Browse the repository at this point in the history
  • Loading branch information
danielaparker committed Oct 30, 2024
1 parent bf0f88b commit 7045e43
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions doc/ref/corelib/json/allocators.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ assert(it != std::end(buffer));
#### Copy construction
`basic_json` copy constructor
The copy constructor
```
Json j1(j);
```
constructs `j1` from `j`. If `j` holds a long string, bytes string, array or object,
constructs `j1` from the contents of `j`. If `j` holds a long string, bytes string, array or object,
copy construction applies allocator traits `select_on_container_copy_construction` to
the allocator from `j` (since 0.178.0) For example:
Expand All @@ -67,13 +67,13 @@ assert(j1.get_allocator() == std::pmr::polymorphic_allocator<char>{}); // expect

#### Allocator-extended copy construction

`basic_json` copy constructor
The allocator-extended copy constructor

```
Json j1(j, alloc);
```

constructs `j1` from `j`. If `j` holds a long string, bytes string, array or object,
constructs `j1` from the contents of `j` using `alloc` as the allocator. If `j` holds a long string, bytes string, array or object,
copy construction uses allocator `alloc` for allocating storage, otherwise `alloc` is ignored. For example:

```cpp
Expand All @@ -96,14 +96,14 @@ assert(j1.get_allocator().resource() == &pool1);
#### Move construction
`basic_json` move construction
The move constructor
```
Json j1(std::move(j));
```
initializes `j1` with the contents of `j`, which is either a pointer or a trivially copyable value,
and changes the value in `j` to `null`. For example:
constructs `j1` by taking the contents of `j`, which has either a pointer or a trivially copyable value,
and replaces it with `null`. For example:
```
char buffer[1024];
Expand All @@ -122,7 +122,13 @@ assert(j.is_null());
#### Allocator-extended move construction
For example:
The allocator-extended move constructor
```
Json j1(std::move(j), alloc);
```
constructs `j1` with a copy of the data member `j`, using `alloc` as the allocator. For example:
```cpp
char buffer[1024];
Expand Down

0 comments on commit 7045e43

Please sign in to comment.