Matthias Vallentin | 1 Mar 2010 03:10
Picon
Favicon
Gravatar

[ptr_container] view_clone_allocator with associative containers

I cannot get the view_clone_allocator to work with associative containers, as
in the example below:

    boost::ptr_vector<int> vec;
    boost::ptr__map<std::string, int, boost::view_clone_allocator> map;

    int* i = new int(42);
    vec.push_back(i);

    std::string k("foo");
    map.insert(k, i);

>From the error message, it seems that the CloneAllocator is still of
type boost::heap_clone_allocator. 

Why is this failing? It seems intuitive to specify the allocator as
third parameter, similar to the example with ptr_vector where the 
allocator is the second argument.

   Matthias
--

-- 
Matthias Vallentin
vallentin <at> icsi.berkeley.edu
http://www.icir.org/matthias
Steven Watanabe | 1 Mar 2010 04:55
Picon

Re: [ptr_container] view_clone_allocator with associative containers

AMDG

Matthias Vallentin wrote:
> I cannot get the view_clone_allocator to work with associative containers, as
> in the example below:
>
>     boost::ptr_vector<int> vec;
>     boost::ptr__map<std::string, int, boost::view_clone_allocator> map;
>
>     int* i = new int(42);
>     vec.push_back(i);
>
>     std::string k("foo");
>     map.insert(k, i);
>
> >From the error message, it seems that the CloneAllocator is still of
> type boost::heap_clone_allocator.
>
> Why is this failing? It seems intuitive to specify the allocator as
> third parameter, similar to the example with ptr_vector where the 
> allocator is the second argument.
>   

The allocator is the fourth argument of ptr_map.  The third argument
is the comparison predicate.

In Christ,
Steven Watanabe
Matthias Vallentin | 1 Mar 2010 14:11
Picon
Favicon
Gravatar

Re: [ptr_container] view_clone_allocator with associative containers

On Sun, Feb 28, 2010 at 07:55:29PM -0800, Steven Watanabe wrote:
> The allocator is the fourth argument of ptr_map.  The third argument
> is the comparison predicate.

Oh yes, that was trivial. Thanks.

   Matthias
--

-- 
Matthias Vallentin
vallentin <at> icsi.berkeley.edu
http://www.icir.org/matthias

Gmane