You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some standard containers have good SSO, like std::string, but others have bad like std::wstring, or some have none, like std::vector. We can make any contiguous container have SSO with custom allocator. With this we can replace global or, more precisely, thread-local objects at the places they are used, which we use to avoid lot of memory allocations by reusing the old buffers.
Some standard containers have good SSO, like
std::string
, but others have bad likestd::wstring
, or some have none, likestd::vector
. We can make any contiguous container have SSO with custom allocator. With this we can replace global or, more precisely, thread-local objects at the places they are used, which we use to avoid lot of memory allocations by reusing the old buffers.An example for such solution is:
A C++ allocator can not give memory from within the same object, thus the following is wrong https://github.com/HowardHinnant/HowardHinnant.github.io/blob/master/stack_alloc.h . Howard Hinnant first wrote the wrong one (
stack_alloc.h
) and then made the correct one (short_alloc.h
).Another solution is to use new features from C++ https://en.cppreference.com/w/cpp/memory/monotonic_buffer_resource . See a tutorial for that. These features are still not implemented in LLVM's libc++.
The text was updated successfully, but these errors were encountered: