Boost logo

Boost :

Subject: Re: [boost] [unordered] Buffered functions?
From: David Abrahams (dave_at_[hidden])
Date: 2008-11-25 16:42:33


on Mon Nov 24 2008, "Daniel James" <daniel_james-AT-fmail.co.uk> wrote:

> 2008/11/24 Thorsten Ottosen <thorsten.ottosen_at_[hidden]>:
>>
>> 1. storing two functors had to do with implementing exception safety if
>> copying of the functors may throw. Was it swap() that was the problem?
>
> Here's the original post where I described the problem:
>
> http://lists.boost.org/Archives/boost/2005/02/80211.php
>
> I think it also applies to assignment.

This looks like a bug in the standard. Equality and hashing should be
required to be nothrow-swappable. I've raised that issue on the
committee reflector.

>> 2. the space optimization only gave little less space.
>
> The cost from not using EBO amounts to a few bytes - which can
> sometimes be offset due to alignment. Since 4 bytes is typically
> required per bucket it doesn't seem like a large amount.

Some people really care about the space taken up by an empty container.

> Early versions used boost::compressed_pair but that had poor support
> for Visual C++ 6 (which I supported at the time).

I hope that's a non-issue now :-)

> I've been thinking about reintroducing EBO, but there have also been
> plenty of other more pressing tasks.
>
> I'd probably implement it manually

Implement _what_ manually?
    
> though, as I don't think using compressed_pair would buy much. I can't
> imagine a situation where the hash function will be empty and the
> equality predicate won't so there isn't much point in the extra
> complexity and dependency. Similarly, I'm not aware of an allocator
> that is empty for a bucket, but not for a node.

It seems like you think compressed pair can only compress away one
member, but IIUC you can chain them and then derive your hash table from
that to compress as much as you like. Of course it would be nice to
have a compressed_tuple that handles it all for us, but I thikn you
_can_ do it.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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