Boost logo

Boost :

From: Joaquin M Lopez Munoz (joaquin_at_[hidden])
Date: 2008-04-02 17:24:43


Amit <contact.lipik <at> gmail.com> writes:

>
> Hi,
>
> I am trying to migrate my project to 1.35. The following used to compile and
> work with 1.34.1:
> bmx::multi_index_container<wstring,
> bmx::indexed_by<bmx::ordered_unique<bmx::identity<wstring> >,
> bmx::random_access<> >,
> boost::fast_pool_allocator<wstring> >
>
> But refuses to compile with 1.35 (I use Intel compiler 10.1 with MSVC7.1 STL).
> Something to do with allocator rebind. I am including some of the compiler
> output below.
>
> Can someone please suggest a resolution (hopefully keeping the pool allocator
> intact)?

Hi Amit,

Steven is right on spot: boost::fast_pool_allocator is not correctly
specialized for void, as it should. I'll file a bug report about this.
In the meantime, you can simply replace fast_pool_allocator with
the following fixed_fast_pool_allocator class:

  template<
    typename T,
    typename UserAllocator=boost::default_user_allocator_new_delete
>
  class fixed_fast_pool_allocator:
    public boost::fast_pool_allocator<T,UserAllocator>
  {
    typedef boost::fast_pool_allocator<T,UserAllocator> super;
  public:
    template<typename U> struct rebind
    {typedef fixed_fast_pool_allocator<U, UserAllocator> other;};

    fixed_fast_pool_allocator(){}
    fixed_fast_pool_allocator(const fixed_fast_pool_allocator&x):super(x){}
    template<typename U> fixed_fast_pool_allocator(
      const fixed_fast_pool_allocator<U,UserAllocator>& x):super(x){}
  };

  template<typename UserAllocator>
  class fixed_fast_pool_allocator<void,UserAllocator>
  {
  public:
    typedef void* pointer;
    typedef const void* const_pointer;
    typedef void value_type;
    template<typename U> struct rebind
    {typedef fixed_fast_pool_allocator<U, UserAllocator> other;};
  };

Does this solve your problem? Please report back. Thanks for
using Boost.MultiIndex,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk