Value type of map need not be default copyable

Paolo Carlini paolo.carlini@oracle.com
Tue Aug 7 22:11:00 GMT 2012


Hi,

(adding in CC Francois too)

On 08/07/2012 11:43 PM, Ollie Wild wrote:
> On Sat, Aug 4, 2012 at 10:34 AM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
>>
>> First, I think we should add libstdc++ in CC.
>>
>> Thus, I would recommend people working in this area to begin with
>> unordered_map, because in that case emplace is already available, assuming
>> that's really the point (and therefore reverting the patch was a good idea,
>> luckily an existing testcase helped us)
>>
>> At the same time an implementation of emplace is definitely welcome, in
>> any case.
> I've attached a patch for unordered_map which solves the rvalue
> reference problem.  For efficiency, I've created a new
> _M_emplace_bucket method rather than call emplace directly.
Patch looks already pretty good to me. A couple of comments:
- Did you consider whether _M_emplace_bucket could be used as an 
implementation detail of_M_emplace? Or figure out in any case a 
smart(er) refactoring to share code with the implementation of 
_M_emplace. I didn't study in detail your code, but I think we can avoid 
some redundancy.
- For consistency at least, I think we should get rid of the make_pair 
in the other overload too.
> I've verified all libstdc++ tests pass (sorry for the previous
> oversight) and am running the full GCC test suite now.  However, I'd
> appreciate any feedback on whether this is a reasonable approach.  STL
> hacking is way outside my comfort zone.  ;-)
>
> If this looks good, I'll take a stab at std::map.
That would be great. We have a PR which remained open way too much time. 
The challenge is figuring out a way to avoid writing too much code 
similar to what we have already for the inserts. Honestly, I tried, a 
while ago, and failed, didn't see an easy way, but in any case, it's 
time to have this stuff implemented - I hear Marc ;) - one way or the 
other, for 4.8.0

Thanks,
Paolo.



More information about the Libstdc++ mailing list