11#ifndef SIMPLE_OBJECT_POOL_H_
12#define SIMPLE_OBJECT_POOL_H_
14#include <boost/pool/pool.hpp>
26class Simple_object_pool :
protected boost::pool<boost::default_user_allocator_malloc_free> {
28 typedef boost::pool<boost::default_user_allocator_malloc_free> Base;
35 Base
const& base()
const {
40 typedef T element_type;
41 typedef boost::default_user_allocator_malloc_free user_allocator;
42 typedef typename Base::size_type size_type;
43 typedef typename Base::difference_type difference_type;
46 Simple_object_pool(U&&...u) : Base(sizeof (T), std::forward<U>(u)...) { }
49 pointer construct(U&&...u) {
50 void* p = base().malloc BOOST_PREVENT_MACRO_SUBSTITUTION();
53 new(p) T(std::forward<U>(u)...);
55 base().free BOOST_PREVENT_MACRO_SUBSTITUTION(p);
58 return static_cast<pointer
> (p);
61 void destroy(pointer p) {
63 base().free BOOST_PREVENT_MACRO_SUBSTITUTION(p);