pool_allocator.hpp
Go to the documentation of this file.
1 #pragma once
2 
15 #include <boost/make_shared.hpp>
16 #include <boost/pool/pool_alloc.hpp>
17 
18 namespace cras
19 {
20 
31 template <typename T, class... Args>
33 {
34  using allocator_t = ::boost::fast_pool_allocator<::boost::shared_ptr<T>>;
35  return ::boost::allocate_shared<T, allocator_t, Args...>(allocator_t(), ::boost::detail::sp_forward<Args>( args )...);
36 }
37 
48 template <typename T, class... Args>
50 {
51  using allocator_t = ::boost::pool_allocator<::boost::shared_ptr<T>>;
52  return ::boost::allocate_shared<T, allocator_t, Args...>(allocator_t(), ::boost::detail::sp_forward<Args>( args )...);
53 }
54 
55 }
boost::shared_ptr
cras
Definition: any.hpp:15
cras::make_shared_from_fast_pool
::boost::shared_ptr< T > make_shared_from_fast_pool(Args &&... args)
Make a shared instance of an object from Boost fast pool (suitable for e.g. elements of a std::list o...
Definition: pool_allocator.hpp:32
cras::make_shared_from_pool
::boost::shared_ptr< T > make_shared_from_pool(Args &&... args)
Make a shared instance of an object from Boost pool (suitable for e.g. elements of a std::vector or a...
Definition: pool_allocator.hpp:49
args
cras::allocator_t
void *(* allocator_t)(size_t)
Allocator function that should allocate a buffer of the given size on the caller side and return a po...
Definition: c_api.h:36


cras_cpp_common
Author(s): Martin Pecka
autogenerated on Tue Nov 26 2024 03:49:04