MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / propagtion

Function propagtion

examples/src/pmr_allocator_examples.cpp:8–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include <cassert>
7
8void propagtion()
9{
10 char buffer[1024];
11 std::pmr::monotonic_buffer_resource pool{ std::data(buffer), std::size(buffer) };
12 std::pmr::polymorphic_allocator<char> alloc(&pool);
13
14 std::string key = "key too long for short string";
15 std::string value = "string too long for short string";
16
17 jsoncons::pmr::json j{ jsoncons::json_object_arg, alloc };
18 assert(j.get_allocator().resource() == &pool);
19
20 j.try_emplace(key, value);
21
22 auto it = std::search(std::begin(buffer), std::end(buffer), key.begin(), key.end());
23 assert(it != std::end(buffer));
24 it = std::search(std::begin(buffer), std::end(buffer), value.begin(), value.end());
25 assert(it != std::end(buffer));
26}
27
28void copy_construction()
29{

Callers 1

mainFunction · 0.85

Calls 8

sizeFunction · 0.85
searchFunction · 0.85
beginFunction · 0.85
endFunction · 0.85
get_allocatorMethod · 0.45
try_emplaceMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected