* [PATCH] Adjust tr1::_Hashtable to work with std::allocator in C++20
@ 2019-10-04 13:18 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2019-10-04 13:18 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 565 bytes --]
In C++20 std::allocator will no longer define construct and destroy
member functions, so using them needs to go via allocator_traits.
* include/tr1/hashtable.h (tr1::_Hashtable::_M_allocate_node): Use
__gnu_cxx::__alloc_traits for allocator construct function.
(tr1::_Hashtable::_M_deallocate_node): Likewise for destroy function.
I forgot to include the necessary header, so there was another patch
to fix that:
* include/tr1/hashtable.h: Add header for __gnu_cxx::__alloc_traits.
Tested x86_64-linux, committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 2465 bytes --]
commit 614abedbab087928017033aa7962e6c2dd3ec5d3
Author: redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri Oct 4 13:17:54 2019 +0000
Add missing header required by previous change
* include/tr1/hashtable.h: Add header for __gnu_cxx::__alloc_traits.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@276576 138bc75d-0d04-0410-961f-82ee72b054a4
diff --git a/libstdc++-v3/include/tr1/hashtable.h b/libstdc++-v3/include/tr1/hashtable.h
index 85fec6a6a14..354d7b814eb 100644
--- a/libstdc++-v3/include/tr1/hashtable.h
+++ b/libstdc++-v3/include/tr1/hashtable.h
@@ -34,6 +34,7 @@
#pragma GCC system_header
#include <tr1/hashtable_policy.h>
+#include <ext/alloc_traits.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
commit 5bf86f5e0fc6567f69eb299eb1c9d4a74f105bb7
Author: redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri Oct 4 12:17:01 2019 +0000
Adjust tr1::_Hashtable to work with std::allocator in C++20
In C++20 std::allocator will no longer define construct and destroy
member functions, so using them needs to go via allocator_traits.
* include/tr1/hashtable.h (tr1::_Hashtable::_M_allocate_node): Use
__gnu_cxx::__alloc_traits for allocator construct function.
(tr1::_Hashtable::_M_deallocate_node): Likewise for destroy function.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@276575 138bc75d-0d04-0410-961f-82ee72b054a4
diff --git a/libstdc++-v3/include/tr1/hashtable.h b/libstdc++-v3/include/tr1/hashtable.h
index c1b5c9e8fda..85fec6a6a14 100644
--- a/libstdc++-v3/include/tr1/hashtable.h
+++ b/libstdc++-v3/include/tr1/hashtable.h
@@ -429,7 +429,9 @@ namespace tr1
_Node* __n = _M_node_allocator.allocate(1);
__try
{
- _M_get_Value_allocator().construct(&__n->_M_v, __v);
+ _Value_allocator_type __a = _M_get_Value_allocator();
+ typedef __gnu_cxx::__alloc_traits<_Value_allocator_type> _Traits;
+ _Traits::construct(__a, &__n->_M_v, __v);
__n->_M_next = 0;
return __n;
}
@@ -449,7 +451,9 @@ namespace tr1
_H1, _H2, _Hash, _RehashPolicy, __chc, __cit, __uk>::
_M_deallocate_node(_Node* __n)
{
- _M_get_Value_allocator().destroy(&__n->_M_v);
+ _Value_allocator_type __a = _M_get_Value_allocator();
+ typedef __gnu_cxx::__alloc_traits<_Value_allocator_type> _Traits;
+ _Traits::destroy(__a, &__n->_M_v);
_M_node_allocator.deallocate(__n, 1);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-10-04 13:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-04 13:18 [PATCH] Adjust tr1::_Hashtable to work with std::allocator in C++20 Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).