forked from Imagelibrary/binutils-gdb
[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.
This commit is contained in:
@@ -18,6 +18,10 @@
|
|||||||
#ifndef COMMON_DEFAULT_INIT_ALLOC_H
|
#ifndef COMMON_DEFAULT_INIT_ALLOC_H
|
||||||
#define COMMON_DEFAULT_INIT_ALLOC_H
|
#define COMMON_DEFAULT_INIT_ALLOC_H
|
||||||
|
|
||||||
|
#if __cplusplus >= 202002L
|
||||||
|
#include <memory_resource>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace gdb {
|
namespace gdb {
|
||||||
|
|
||||||
/* An allocator that default constructs using default-initialization
|
/* An allocator that default constructs using default-initialization
|
||||||
@@ -29,7 +33,14 @@ namespace gdb {
|
|||||||
adapter that given an allocator A, overrides 'A::construct()'. 'A'
|
adapter that given an allocator A, overrides 'A::construct()'. 'A'
|
||||||
defaults to std::allocator<T>. */
|
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
|
class default_init_allocator : public A
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user