Boost logo

Boost Users :

Subject: [Boost-users] [Pool] Use singleton_pool in struct
From: Claude (clros_at_[hidden])
Date: 2012-10-08 04:00:53


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 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