On 11/05/19 00:51 +0300, Ville Voutilainen wrote:
On Sat, 11 May 2019 at 00:42, Jonathan Wakely <jwak...@redhat.com> wrote:
A disabled specialization should not be callable, so move the function
call operator into a new base class which correctly implements the
disabled hash semantics. For the versioned namespace configuration do
not derive from __poison_hash in the enabled case, as the empty base
class serves no purpose but potentially increases the object size. For
the default configuration that base class must be kept, to preserve
layout.
I continue to not be a fan of the versioned namespace ifdeffery in
this, but I can live with it.
The versioned namespace configuration should be as good as we can make
it, with no limitations due to ABI compatibility. Removing redundant
base classes allows more compact class layouts. With current trunk
this type has size 3, in the versioned namespace after my patch it has
size 2 (and if we patched hash<optional<T>> it would have size 1):
template<typename T>
struct HashPtr
: std::hash<T*>,
std::hash<std::optional<T*>>,
std::hash<std::optional<T* const>>,
std::hash<std::unique_ptr<T>>
{
};