Boost logo

Boost Users :

Subject: Re: [Boost-users] [Pool] Use singleton_pool in struct
From: Piotr Kowalski (koval.gnu_at_[hidden])
Date: 2012-10-08 07:57:09


Hi Claude,
Since the first usage compiles fine I guess "malloc" is a static method of
boost::singleton_pool
Try changing your call to
myStruct::poolMemory::malloc

Regards,
koval

2012/10/8 Claude <clros_at_[hidden]>

> Hi!
> I have a problem with singleton_pool when I use it into a struct.
> I think that this problem is my bad knowledge of C++ and not a problem of
> boost pool.
>
> #include <iostream>
> #include <boost/pool/pool_alloc.hpp>
>
> using namespace std;
>
> struct data
> {
> int a,b;
> char name[50];
> };
>
>
> struct MyOrderTag {};
> typedef boost::singleton_pool<MyOrderTag,sizeof(data)> poolMemory;
>
>
> struct myStruct
> {
> struct MyOrderTag {};
> typedef boost::singleton_pool<MyOrderTag,sizeof(data)> poolMemory;
> };
>
>
> int main()
> {
> data *d = (data*)poolMemory::malloc(); //This is ok
>
> myStruct ms;
> // data *d1 = (data*)ms.poolMemory::malloc(); //Error!
>
> d->a = 2;
>
>
> poolMemory::release_memory();
> return 0;
> }
>
> I obtain a compiler error on row:
> data *d1 = (data*)ms.poolMemory::malloc();
> The poolMemory in struct is only a typedef and not a struct field.
> How can I use a singleton_pool into a struct?
>
>
>
>
>
>
>
> --
> View this message in context:
> http://boost.2283326.n4.nabble.com/Pool-Use-singleton-pool-in-struct-tp4636741.html
> Sent from the Boost - Users mailing list archive at Nabble.com.
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net