| 108 | //---------------------------------------------------------- |
| 109 | |
| 110 | static void set1() { |
| 111 | using namespace background; |
| 112 | |
| 113 | //---------------------------------------------------------- |
| 114 | { |
| 115 | struct T {}; |
| 116 | // tag::doc_background_5[] |
| 117 | // A type of memory resource |
| 118 | monotonic_resource mr; |
| 119 | |
| 120 | // Construct a vector using the monotonic buffer resource |
| 121 | vector< T > v1(( boost::container::pmr::polymorphic_allocator< T >(&mr) )); |
| 122 | |
| 123 | // Or this way, since construction from memory_resource* is implicit: |
| 124 | vector< T > v2( &mr ); |
| 125 | // end::doc_background_5[] |
| 126 | } |
| 127 | //---------------------------------------------------------- |
| 128 | { |
| 129 | // tag::doc_background_6[] |
| 130 | { |
| 131 | // A type of memory resource which uses a stack buffer |
| 132 | unsigned char temp[4096]; |
| 133 | static_resource mr( temp, sizeof(temp) ); |
| 134 | |
| 135 | // Construct a vector using the static buffer resource |
| 136 | vector< value > v( &mr ); |
| 137 | |
| 138 | // The vector will allocate from `temp` first, and then the heap. |
| 139 | } |
| 140 | // end::doc_background_6[] |
| 141 | } |
| 142 | //---------------------------------------------------------- |
| 143 | |
| 144 | } // set1 |
| 145 | |
| 146 | //---------------------------------------------------------- |
| 147 |
nothing calls this directly
no outgoing calls
no test coverage detected