|
Boost : |
Subject: Re: [boost] [interprocess][multi_index] emplace() is not sufficient for maps
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2009-08-22 06:23:40
Ion Gaztañaga skrev:
> Thorsten Ottosen escribió:
>>> Is it too expensive to use move insertion from a type with non-const
>>> key?
>>>
>>> //note that key is non-const!
>>> std::pair<key_type, value_type> v(/**/);
>>>
>>> m.insert(boost::move(v));
>>
>> Yes, because the mapped object is not fast to move. The way I code
>> around it currently is to allocate all state in an object on the heap.
>> I then do
>>
>> PriorityMap::iterator i = open_.emplace( &nodes_.back() );
>> i->second.swap( newData );
>>
>> since swap is now efficient. But it is still not optimally efficient.
>
> Ok, I'll think about it. And you can't implement "move" on top of of
> "swap" to make it efficient (although not optimal, obviously)?
no. See below.
> And I'm curious to know why move construction is expensive. Some c-array
> members, maybe?.
A stack-based adjacency matrix and more stuff, actually.
I'm trying to save one heap-allocation here per node, which might not
sound like much. But the stuff I work with needs to make an exponential
number of nodes.
-Thorsten
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk