Re: Boost compile error when a object of type pool is contained in another class
mackenzie wrote:
On Jun 13, 4:54 pm, "Victor Bazarov" <v.Abaza...@comAcast.net> wrote:
mackenzie wrote:
Hello,
I am looking for a little bit of help. I am trying to create a
dynamically allocated object which contains one or more objects of
type boost::pool<>. I get a compiler error when an object of this
type is contained in my class and am not sure why. To be honest I
have a little but not a lot of experience with templates and it
could simply be obvious to a more experienced template user;
however, the answer escapes me.
Here is a sample code snippet:
#include <boost/pool/pool.hpp>
#include <boost/pool/singleton_pool.hpp>
struct Foobar
{
boost::pool<> p(sizeof(int)); // this is line 182
What's the 'sizeof' for? Are you trying to initialise it? If so,
initialisation of members belongs to constructor initialiser list.
If you were trying to declare an array, then replace parentheses
with brackets. Most likely you just need to lose the parentheses
and the expression inside them.
[..]
What I thought I was doing was creating a member of Foobar named p of
type boost::pool<> which takes a size_type as an argument to the
constructor.
You're trying to provide a particular argument in a declaration.
That's not how you initialise the member. Please read about
constructors (of classes) and the _member_initialiser_lists_.
It seems to work in the global name space; however, when
I put it into a structure or class I get the error.
From : http://www.boost.org/libs/pool/doc/interfaces/pool.html
template <typename UserAllocator = default_user_allocator_new_delete>
class pool
{...
explicit pool(size_type requested_size);
};
Perhaps after the drive home and a clearer head I will stare at it
some more with your suggestion in mind and the answer will be a little
more obvious.
Thanks,
Parker
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask