mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-30 12:44:10 +08:00
[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:
parent
9246b7bd6d
commit
6feae66da1
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user