From Jason Turner

[mem.res.monotonic.buffer]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmppyd8e64o/{from.md → to.md} +16 -16
tmp/tmppyd8e64o/{from.md → to.md} RENAMED
@@ -18,20 +18,20 @@ memory resource object is destroyed. It has the following qualities:
18
  with one another.
19
  - It frees the allocated memory on destruction, even if `deallocate` has
20
  not been called for some of the allocated blocks.
21
 
22
  ``` cpp
 
23
  class monotonic_buffer_resource : public memory_resource {
24
  memory_resource* upstream_rsrc; // exposition only
25
  void* current_buffer; // exposition only
26
  size_t next_buffer_size; // exposition only
27
 
28
  public:
29
  explicit monotonic_buffer_resource(memory_resource* upstream);
30
  monotonic_buffer_resource(size_t initial_size, memory_resource* upstream);
31
- monotonic_buffer_resource(void *buffer, size_t buffer_size,
32
- memory_resource *upstream);
33
 
34
  monotonic_buffer_resource()
35
  : monotonic_buffer_resource(get_default_resource()) {}
36
  explicit monotonic_buffer_resource(size_t initial_size)
37
  : monotonic_buffer_resource(initial_size, get_default_resource()) {}
@@ -40,45 +40,45 @@ public:
40
 
41
  monotonic_buffer_resource(const monotonic_buffer_resource&) = delete;
42
 
43
  virtual ~monotonic_buffer_resource();
44
 
45
- monotonic_buffer_resource
46
- operator=(const monotonic_buffer_resource&) = delete;
47
 
48
  void release();
49
  memory_resource* upstream_resource() const;
50
 
51
  protected:
52
  void* do_allocate(size_t bytes, size_t alignment) override;
53
  void do_deallocate(void* p, size_t bytes, size_t alignment) override;
54
 
55
  bool do_is_equal(const memory_resource& other) const noexcept override;
56
  };
 
57
  ```
58
 
59
- #### `monotonic_buffer_resource` constructor and destructor <a id="mem.res.monotonic.buffer.ctor">[[mem.res.monotonic.buffer.ctor]]</a>
60
 
61
  ``` cpp
62
  explicit monotonic_buffer_resource(memory_resource* upstream);
63
  monotonic_buffer_resource(size_t initial_size, memory_resource* upstream);
64
  ```
65
 
66
- *Requires:* `upstream` shall be the address of a valid memory resource.
67
- `initial_size`, if specified, shall be greater than zero.
68
 
69
  *Effects:* Sets `upstream_rsrc` to `upstream` and `current_buffer` to
70
  `nullptr`. If `initial_size` is specified, sets `next_buffer_size` to at
71
  least `initial_size`; otherwise sets `next_buffer_size` to an
72
  *implementation-defined* size.
73
 
74
  ``` cpp
75
  monotonic_buffer_resource(void* buffer, size_t buffer_size, memory_resource* upstream);
76
  ```
77
 
78
- *Requires:* `upstream` shall be the address of a valid memory resource.
79
- `buffer_size` shall be no larger than the number of bytes in `buffer`.
80
 
81
  *Effects:* Sets `upstream_rsrc` to `upstream`, `current_buffer` to
82
  `buffer`, and `next_buffer_size` to `buffer_size` (but not less than 1),
83
  then increases `next_buffer_size` by an *implementation-defined* growth
84
  factor (which need not be integral).
@@ -87,11 +87,11 @@ factor (which need not be integral).
87
  ~monotonic_buffer_resource();
88
  ```
89
 
90
  *Effects:* Calls `release()`.
91
 
92
- #### `monotonic_buffer_resource` members <a id="mem.res.monotonic.buffer.mem">[[mem.res.monotonic.buffer.mem]]</a>
93
 
94
  ``` cpp
95
  void release();
96
  ```
97
 
@@ -110,14 +110,15 @@ memory_resource* upstream_resource() const;
110
 
111
  ``` cpp
112
  void* do_allocate(size_t bytes, size_t alignment) override;
113
  ```
114
 
115
- *Returns:* A pointer to allocated storage
116
- ([[basic.stc.dynamic.deallocation]]) with a size of at least `bytes`.
117
- The size and alignment of the allocated memory shall meet the
118
- requirements for a class derived from `memory_resource` ([[mem.res]]).
 
119
 
120
  *Effects:* If the unused space in `current_buffer` can fit a block with
121
  the specified `bytes` and `alignment`, then allocate the return block
122
  from `current_buffer`; otherwise set `current_buffer` to
123
  `upstream_rsrc->allocate(n, m)`, where `n` is not less than
@@ -141,8 +142,7 @@ its destruction.
141
 
142
  ``` cpp
143
  bool do_is_equal(const memory_resource& other) const noexcept override;
144
  ```
145
 
146
- *Returns:*
147
- `this == dynamic_cast<const monotonic_buffer_resource*>(&other)`.
148
 
 
18
  with one another.
19
  - It frees the allocated memory on destruction, even if `deallocate` has
20
  not been called for some of the allocated blocks.
21
 
22
  ``` cpp
23
+ namespace std::pmr {
24
  class monotonic_buffer_resource : public memory_resource {
25
  memory_resource* upstream_rsrc; // exposition only
26
  void* current_buffer; // exposition only
27
  size_t next_buffer_size; // exposition only
28
 
29
  public:
30
  explicit monotonic_buffer_resource(memory_resource* upstream);
31
  monotonic_buffer_resource(size_t initial_size, memory_resource* upstream);
32
+ monotonic_buffer_resource(void* buffer, size_t buffer_size, memory_resource* upstream);
 
33
 
34
  monotonic_buffer_resource()
35
  : monotonic_buffer_resource(get_default_resource()) {}
36
  explicit monotonic_buffer_resource(size_t initial_size)
37
  : monotonic_buffer_resource(initial_size, get_default_resource()) {}
 
40
 
41
  monotonic_buffer_resource(const monotonic_buffer_resource&) = delete;
42
 
43
  virtual ~monotonic_buffer_resource();
44
 
45
+ monotonic_buffer_resource& operator=(const monotonic_buffer_resource&) = delete;
 
46
 
47
  void release();
48
  memory_resource* upstream_resource() const;
49
 
50
  protected:
51
  void* do_allocate(size_t bytes, size_t alignment) override;
52
  void do_deallocate(void* p, size_t bytes, size_t alignment) override;
53
 
54
  bool do_is_equal(const memory_resource& other) const noexcept override;
55
  };
56
+ }
57
  ```
58
 
59
+ #### Constructors and destructor <a id="mem.res.monotonic.buffer.ctor">[[mem.res.monotonic.buffer.ctor]]</a>
60
 
61
  ``` cpp
62
  explicit monotonic_buffer_resource(memory_resource* upstream);
63
  monotonic_buffer_resource(size_t initial_size, memory_resource* upstream);
64
  ```
65
 
66
+ *Preconditions:* `upstream` is the address of a valid memory resource.
67
+ `initial_size`, if specified, is greater than zero.
68
 
69
  *Effects:* Sets `upstream_rsrc` to `upstream` and `current_buffer` to
70
  `nullptr`. If `initial_size` is specified, sets `next_buffer_size` to at
71
  least `initial_size`; otherwise sets `next_buffer_size` to an
72
  *implementation-defined* size.
73
 
74
  ``` cpp
75
  monotonic_buffer_resource(void* buffer, size_t buffer_size, memory_resource* upstream);
76
  ```
77
 
78
+ *Preconditions:* `upstream` is the address of a valid memory resource.
79
+ `buffer_size` is no larger than the number of bytes in `buffer`.
80
 
81
  *Effects:* Sets `upstream_rsrc` to `upstream`, `current_buffer` to
82
  `buffer`, and `next_buffer_size` to `buffer_size` (but not less than 1),
83
  then increases `next_buffer_size` by an *implementation-defined* growth
84
  factor (which need not be integral).
 
87
  ~monotonic_buffer_resource();
88
  ```
89
 
90
  *Effects:* Calls `release()`.
91
 
92
+ #### Members <a id="mem.res.monotonic.buffer.mem">[[mem.res.monotonic.buffer.mem]]</a>
93
 
94
  ``` cpp
95
  void release();
96
  ```
97
 
 
110
 
111
  ``` cpp
112
  void* do_allocate(size_t bytes, size_t alignment) override;
113
  ```
114
 
115
+ *Returns:* A pointer to allocated
116
+ storage [[basic.stc.dynamic.allocation]] with a size of at least
117
+ `bytes`. The size and alignment of the allocated memory shall meet the
118
+ requirements for a class derived from `memory_resource`
119
+ [[mem.res.class]].
120
 
121
  *Effects:* If the unused space in `current_buffer` can fit a block with
122
  the specified `bytes` and `alignment`, then allocate the return block
123
  from `current_buffer`; otherwise set `current_buffer` to
124
  `upstream_rsrc->allocate(n, m)`, where `n` is not less than
 
142
 
143
  ``` cpp
144
  bool do_is_equal(const memory_resource& other) const noexcept override;
145
  ```
146
 
147
+ *Returns:* `this == &other`.
 
148