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

Function copy_construction

examples/src/pmr_allocator_examples.cpp:28–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26}
27
28void copy_construction()
29{
30 char buffer[1024];
31 std::pmr::monotonic_buffer_resource pool{ std::data(buffer), std::size(buffer) };
32 std::pmr::polymorphic_allocator<char> alloc(&pool);
33
34 jsoncons::pmr::json j{ "String too long for short string", alloc };
35 assert(j.is_string());
36 assert(j.get_allocator().resource() == &pool);
37
38 jsoncons::pmr::json j1(j);
39 assert(j1 == j);
40 assert(j1.get_allocator() == std::allocator_traits<std::pmr::polymorphic_allocator<char>>::
41 select_on_container_copy_construction(j.get_allocator()));
42 assert(j1.get_allocator() == std::pmr::polymorphic_allocator<char>{}); // expected result for pmr allocators
43}
44
45void allocator_extended_copy_construction() // extended copy
46{

Callers 1

mainFunction · 0.85

Calls 3

sizeFunction · 0.85
is_stringMethod · 0.80
get_allocatorMethod · 0.45

Tested by

no test coverage detected