#include <gtest/gtest.h>
#include <gmock/gmock.h>
struct Message
{
: data{allocator}
{
}
};
static constexpr std::size_t SmallMessageSizeBytes = 64 * 8;
static struct alignas(std::max_align_t)
{
}small_message_buffer_;
TEST(example_04_buffer_memory_resource, example_a)
{
Message a{aAlloc};
const std::size_t item_cout = SmallMessageSizeBytes /
sizeof(
decltype(aAlloc)::value_type);
a.data.reserve(item_cout);
std::cout <<
"BEFORE -> data size = " << a.data.size() <<
", data capacity : " << a.data.capacity() <<
std::endl;
{
a.data.push_back(i);
}
std::cout <<
"AFTER -> data size = " << a.data.size() <<
", data capacity : " << a.data.capacity() <<
std::endl;
}
TEST(example_04_buffer_memory_resource, example_b)
{
SmallMessageSizeBytes,
cetl::pf17::pmr::new_delete_resource(),
Message b{bAlloc};
std::cout <<
"BEFORE -> data size = " << b.data.size() <<
", data capacity : " << b.data.capacity() <<
std::endl;
const std::size_t item_cout = (SmallMessageSizeBytes /
sizeof(
decltype(bAlloc)::value_type)) * 100;
{
b.data.push_back(i);
}
std::cout <<
"AFTER -> data size = " << b.data.size() <<
", data capacity : " << b.data.capacity() <<
std::endl;
}
TEST(example_04_buffer_memory_resource, example_c)
{
SmallMessageSizeBytes,
&cUpstreamResource,
Message c{cAlloc};
std::cout <<
"BEFORE -> data size = " << c.data.size() <<
", data capacity : " << c.data.capacity() <<
std::endl;
const std::size_t item_cout = SmallMessageSizeBytes /
sizeof(
decltype(cAlloc)::value_type);
{
c.data.push_back(i);
}
std::cout <<
"AFTER -> data size = " << c.data.size() <<
", data capacity : " << c.data.capacity() <<
std::endl;
}
Defines memory_resource types for that are backed by simple contiguous blocks of memory and use cetl:...
Implementation of cetl::pf17::pmr::memory_resource that uses cetl::pmr::UnsynchronizedBufferMemoryRes...
Definition buffer_memory_resource.hpp:41
Adheres to the std::pmr::polymorphic_allocator specification.
Definition memory_resource.hpp:356
byte
A non-character type that implements the concept of a byte defined by the C++17 specification.
Definition byte.hpp:26
Extends the cetl::pf17::pmr namespace with system memory resources.