diff mbox

fix libstdc++/56278

Message ID 511C017D.2090700@gmail.com
State New
Headers show

Commit Message

François Dumont Feb. 13, 2013, 9:11 p.m. UTC
Committed then.

2013-02-13  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.


On 02/13/2013 12:36 PM, Jonathan Wakely wrote:
> On 13 February 2013 10:19, Paolo Carlini wrote:
>> On 02/12/2013 09:54 PM, François Dumont wrote:
>>>      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.
>> I like it. Thanks Francois. If Jon has no objections over the next day or
>> so, please go ahead.
> No objection, I agree it's suitable for 4.8 as it's refining my
> regression fix, but I don't think it really makes any difference.
> There is nothing required by C++11 for _Hash_code_base's constructors
> because it's an implementation detail, and the only way a user can
> tell the difference between a public and protected constructor is
> trying to construct _Hash_code_base directly, which is obviously
> unsupported.
>
diff mbox

Patch

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");