#pragma once #include #include #include #include // based on boost::core::noinit_adaptor // The goal is to avoid initialization of the content of a container, // because setting several kB of uint8_t to 0 has a real cost if you // do 100k times per second. template struct noinit_adaptor: Allocator { template struct rebind { typedef noinit_adaptor::template rebind_alloc > other; }; noinit_adaptor(): Allocator() { } template noinit_adaptor(U&& u) noexcept : Allocator(std::forward(u)) { } template noinit_adaptor(const noinit_adaptor& u) noexcept : Allocator(static_cast(u)) { } template void construct(U* p) { ::new((void*)p) U; } template void construct(U* p, V&& v, Args&&... args) { ::new((void*)p) U(std::forward(v), std::forward(args)...); } template void destroy(U* p) { p->~U(); } }; template inline bool operator==(const noinit_adaptor& lhs, const noinit_adaptor& rhs) noexcept { return static_cast(lhs) == static_cast(rhs); } template inline bool operator!=(const noinit_adaptor& lhs, const noinit_adaptor& rhs) noexcept { return !(lhs == rhs); } template inline noinit_adaptor noinit_adapt(const Allocator& a) noexcept { return noinit_adaptor(a); } template using NoInitVector = std::vector>>; using PacketBuffer = NoInitVector;