This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [patch] fix libstdc++/56278
On 02/11/2013 01:21 AM, Jonathan Wakely wrote:
PR libstdc++/56278
* include/bits/hashtable_policy.h (_Hash_code_base): Make default
constructor public.
* testsuite/23_containers/unordered_set/56278.cc: New.
Tested x86_64-linux, committed to trunk.
In fact we do not need the default constructor to be public. It is
the static assertion in hashtable that is not accurate enough.
std::is_default_constructible is in fact a
std::is_publicly_default_constructible which is more than we need. Here
is a patch that restore default constructor protected and check that
_Hash_code_base is default constructible through inheritance.
Of course this is not mandatory but I think _Hash_code_base would
be cleaner this way only exposing as public what is required by C++11.
It can also wait for 4.9.
Tested under Linux x86_64.
2013-02-12 François Dumont <fdumont@gcc.gnu.org>
* include/bits/hashtable_policy.h (_Hash_code_base): Restore
default constructor protected.
* include/bits/hashtable.h: static assert that _Hash_code_base has
a default constructor available through inheritance.
François
Index: include/bits/hashtable_policy.h
===================================================================
--- include/bits/hashtable_policy.h (revision 195955)
+++ include/bits/hashtable_policy.h (working copy)
@@ -918,15 +918,13 @@
using __ebo_extract_key = _Hashtable_ebo_helper<0, _ExtractKey>;
using __ebo_hash = _Hashtable_ebo_helper<1, _Hash>;
- public:
- // We need the default constructor for the local iterators.
- _Hash_code_base() = default;
-
protected:
typedef void* __hash_code;
typedef _Hash_node<_Value, false> __node_type;
- protected:
+ // We need the default constructor for the local iterators.
+ _Hash_code_base() = default;
+
_Hash_code_base(const _ExtractKey& __ex, const _H1&, const _H2&,
const _Hash& __h)
: __ebo_extract_key(__ex), __ebo_hash(__h) { }
@@ -1004,13 +1002,13 @@
hash_function() const
{ return _M_h1(); }
- // We need the default constructor for the local iterators.
- _Hash_code_base() = default;
-
protected:
typedef std::size_t __hash_code;
typedef _Hash_node<_Value, false> __node_type;
+ // We need the default constructor for the local iterators.
+ _Hash_code_base() = default;
+
_Hash_code_base(const _ExtractKey& __ex,
const _H1& __h1, const _H2& __h2,
const _Default_ranged_hash&)
Index: include/bits/hashtable.h
===================================================================
--- include/bits/hashtable.h (revision 195955)
+++ include/bits/hashtable.h (working copy)
@@ -266,7 +266,10 @@
// __hash_code_base above to compute node bucket index so it has to be
// default constructible.
static_assert(__if_hash_not_cached<
- is_default_constructible<__hash_code_base>>::value,
+ is_default_constructible<
+ // We use _Hashtable_ebo_helper to access the protected
+ // default constructor.
+ __detail::_Hashtable_ebo_helper<0, __hash_code_base>>>::value,
"Cache the hash code or make functors involved in hash code"
" and bucket index computation default constructible");