diff options
author | Tom de Vries <tdevries@suse.de> | 2023-08-17 10:41:34 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2023-08-17 10:41:34 +0200 |
commit | 6feae66da1d652a50c1759bae46128087f7dfab0 (patch) | |
tree | 187e50cc00b6309df206cfd9d66bbb8e38d9adec | |
parent | 9246b7bd6dfeb273f9be7648acffddfe19f966ff (diff) | |
download | gdb-6feae66da1d652a50c1759bae46128087f7dfab0.zip gdb-6feae66da1d652a50c1759bae46128087f7dfab0.tar.gz gdb-6feae66da1d652a50c1759bae46128087f7dfab0.tar.bz2 |
[gdb/build, c++20] Handle deprecated std::allocator::construct
When building gdb with -std=c++20, I run into:
...
gdbsupport/default-init-alloc.h:52:12: error: ‘construct’ has not been \
declared in ‘class std::allocator<unsigned char>’
52 | using A::construct;
| ^~~~~~~~~
...
Indeed, std::allocator::construct has been deprecated in c++17 and removed in
c++20.
Fix this by using instead std::pmr::polymorphic_allocator for c++20.
Tested on x86_64-linux.
-rw-r--r-- | gdbsupport/default-init-alloc.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/gdbsupport/default-init-alloc.h b/gdbsupport/default-init-alloc.h index 9c8b5a2..e2d3bd2 100644 --- a/gdbsupport/default-init-alloc.h +++ b/gdbsupport/default-init-alloc.h @@ -18,6 +18,10 @@ #ifndef COMMON_DEFAULT_INIT_ALLOC_H #define COMMON_DEFAULT_INIT_ALLOC_H +#if __cplusplus >= 202002L +#include <memory_resource> +#endif + namespace gdb { /* An allocator that default constructs using default-initialization @@ -29,7 +33,14 @@ namespace gdb { adapter that given an allocator A, overrides 'A::construct()'. 'A' defaults to std::allocator<T>. */ -template<typename T, typename A = std::allocator<T>> +template<typename T, + typename A +#if __cplusplus >= 202002L + = std::pmr::polymorphic_allocator<T> +#else + = std::allocator<T> +#endif + > class default_init_allocator : public A { public: |