File: allocator_set.md

package info (click to toggle)
jsoncons 1.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 17,584 kB
  • sloc: cpp: 136,382; sh: 33; makefile: 5
file content (63 lines) | stat: -rw-r--r-- 2,127 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
### jsoncons::allocator_set

```cpp
#include <jsoncons/allocator_set.hpp>

template< 
    typename Allocator,typename TempAllocator
> allocator_set;
```

Member type                         |Definition
------------------------------------|------------------------------
`allocator_type`|`Allocator`
`temp_allocator_type`|`TempAllocator`

#### Constructors

    allocator_set(const Allocator& alloc=Allocator(), const TempAllocator& temp_alloc=TempAllocator())
Constructs an `allocator_set` with an allocator for result data and a
second allocator for temporary allocations. 

    allocator_set(const allocator_set& other)
Copy constructor. 

    allocator_set(allocator_set&& other)

Move constructor. 

#### Accessors

    Allocator get_allocator() const;
Returns an allocator object for result data

    TempAllocator get_temp_allocator() const;
Returns an allocator object for for temporary allocations

#### Helper functions

    template <typename Allocator,typename TempAllocator>
    allocator_set<Allocator,TempAllocator> combine_allocators(
        const Allocator& alloc, const TempAllocator& temp_alloc);

Combines an allocator for result data and an allocator for temporary allocations into an `allocator_set` object,
deducing the allocator types from the types of the arguments.

    allocator_set<std::allocator<char>,std::allocator<char>> combine_allocators()
Creates an `allocator_set<std::allocator<char>,std::allocator<char>>` object with default allocators for result data
and temporary allocations.

    template <typename Allocator>
    allocator_set<Allocator,std::allocator<char>> combine_allocators(
        const Allocator& alloc);

Creates an `allocator_set` with the provided allocator for result data and
defaulting to a `std::allocator<char>` for temporary allocations. 

    template <typename TempAllocator>
    allocator_set<std::allocator<char>,TempAllocator> temp_allocator_only(const TempAllocator& temp_alloc)

Creates a `allocator_set` object, defaulting the result allocator type to `std::allocator<char>`
and deducing the temp allocator type from the type of the `temp_alloc` argument.