I think a C++ library is "elegant" if the number of header files which must be included are as less as possible.
I know there have been existing fixed-size allocators like Loki::SmallObjectAllocator
and boost::pool
. Although both are excellent, I think they are not elegant and not easy to be seamlessly integrated into projects.
Most times, I only need a little part of boost library, but I have to install the whole library on my machine. For example, if I want to use boost::pool, I hope to just include ONE header file boost_pool.h
and the work is done. Because I think a fixed-size allocator should not be so dependent on too many other components. In my opinion, ideal code should look like the following:
#include <boost_pool.h>
int main()
{
boost::pool<int> p;
int* v = p.allocate();
}
Does there exist such a library?
You are welcome to mine. Whether it is elegant or not, you can decide. But it is just one short header dependent upon just a couple of small standard headers. The allocator meets the C++11 allocator requirements, which are a subset of the C++03 allocator requirements. You can always add the C++03 boiler plate if you need it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With