boost::pool<> constructor takes “element size” parameter.
boost::object_pool constructor takes “initial # of element” parameter.
I want to create pool with “element size S” and “initial N of element”.
Is this possible with boost::pool ?
Thank you
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can do that with
object_pool; it infers the size of its element based on theElementTypetemplate parameter, so there is no need to specify a size explicitly. You can specify the requested number of chunks (your ‘N’) as an additional constructor parameter.Update based on OP comments:
From the
boost::poolsource:So you can just do this:
If you want a pool that returns chunks of size 8 ints, and makes an initial allocation of 64 * 8 ints. After you exceed the initial allocation of chunks, storage will be doubled.