Open C++ Libraries: allocator_op.hpp: Overview

Published December 12, 2025

allocator_op.hpp: Overview

I: Abstract.

The pattern is a low-level system allocator designed to handle custom or standard allocators in the C++ programming language. Available on the Open C++ Libraries, its purpose is to serve custom allocators and pools for C++ developers.

II: Usages.

You can only use smart pointers using this type, the rationale is because we'd rather enforce RAII than taking care of deallocation ourselves. As the allocation operators may be susceptible to memory leaks.

using int_alloc_type = ocl::allocator<int>;

int_alloc_type alloc;
std::shared_ptr<int> ptr = alloc.construct_array<1>();
*ptr = 5;
/// gets freed by the ABI using RAII!

III: Conclusion

I hope this pattern and the Open C++ Libraries will be useful to C++ developers! The library also includes Hashing, and a separate FIX submodule. Amlal.

IV: References

  • https://github.com/ocl-org/core/blob/develop/include/ocl/allocator_op.hpp