MCPcopy Create free account
hub / github.com/boostorg/json / set1

Function set1

test/doc_background.cpp:110–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108//----------------------------------------------------------
109
110static void set1() {
111using namespace background;
112
113//----------------------------------------------------------
114{
115struct T {};
116// tag::doc_background_5[]
117// A type of memory resource
118monotonic_resource mr;
119
120// Construct a vector using the monotonic buffer resource
121vector< T > v1(( boost::container::pmr::polymorphic_allocator< T >(&mr) ));
122
123// Or this way, since construction from memory_resource* is implicit:
124vector< 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected