views:

200

answers:

1

I'm keen on using boost's object_pool class for memory re-use for a set of video frames.

boost::object_pool< VideoFrame > FramePool;

Now, the VideoFrame class has two constructors. The first version of the constructor takes 4 arguments while the second version takes 6 arguments/parameters.

For every "new" video frame that is allocated, I would like to call the constructor on the object either using the 4 or 6 parameter version. For example:

//VideoFrame *F = new VideoFrame(IdeckLinkOutput, &R, PixelFormat, FrameFlags);
VideoFrame *F = FramePool.construct(IdeckLinkOutput, &R, PixelFormat, FrameFlags);

Building this on MSVS 2005, I receive the error:

error C2660: 'boost::object_pool<T>::construct' : function does not take 4 arguments

According to the documentation on the 'construct' method of object_pool, "ElementType must have a constructor matching ???; the number of parameters given must not exceed what is supported through pool_construct"

I've seen boost's page for the pool_construct, but I'm not too sure the direction I need to take. The build of boost that I have on my machine has both a pool_construct.m4, pool_construct.sh, pool_construct.bat, pool_construct.inc. It's a question of what do I do with these example files within my own project? Would I create my own variation of pool_construct.inc and include that in my own project? How would I add the file?

Any tips/recommendations would be much appreciated. Please note that I have installed gnu's m4.

zerodefect.

A: 

If I look at /usr/include/boost/pool/detail/pool_construct.inc on my Debian machine (sorry don't have access to MSVC currently), I see it only supports up to 3 constructor arguments.

Messing with m4 as per the documentation to support more than the supported 3 sounds like a pain compared with simply creating a new constructor which bundles enough of the arguments in a single struct or boost::tuple to bring the total passed down to the number supported.

timday
Cool...thanks for that.
ZeroDefect