This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: RE : Problem with _Hashtable_ebo_helper
- From: Jason Merrill <jason at redhat dot com>
- To: frs dot dumont at gmail dot com, libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Wed, 23 Oct 2013 09:06:44 -0400
- Subject: Re: RE : Problem with _Hashtable_ebo_helper
- Authentication-results: sourceware.org; auth=none
- References: <526590F3 dot 6070505 at redhat dot com> <s68065723591507235000 at gmail dot com>
On 10/23/2013 02:53 AM, frs.dumont@gmail.com wrote:
That is indeed an issue. We have to force the 3rd template parameter to
true in this context because we are using _Hastable_ebo_helper here only
for convenience to access protected default ctor if any. We know that
_Hashtable_code_base is not final so it is safe to force true. I'll
submit a patch when back home.
What do you think about this more general change?
Jason
diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h
index ed9e9dd..01adeb6 100644
--- a/libstdc++-v3/include/bits/hashtable_policy.h
+++ b/libstdc++-v3/include/bits/hashtable_policy.h
@@ -969,10 +969,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* Primary class template _Hashtable_ebo_helper.
*
* Helper class using EBO when it is not forbidden (the type is not
- * final) and when it is worth it (the type is empty.)
+ * final) and when it is worth it (the type is empty) or necessary (the
+ * type has a protected default constructor).
*/
template<int _Nm, typename _Tp,
- bool __use_ebo = !__is_final(_Tp) && __is_empty(_Tp)>
+ bool __use_ebo = (!__is_final(_Tp)
+ && (__is_empty(_Tp)
+ || !is_default_constructible<_Tp>::value))>
struct _Hashtable_ebo_helper;
/// Specialization using EBO.