From 2371d51bf53b09441355a1d5500f62109bcb126a Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Tue, 9 Jan 2024 21:27:48 -0800 Subject: Accommodate libc++ upgrade and C++20 C++20 removes the `pointer` member from std::allocator, and it also removes the `allocate` method which takes a hint parameter. Newer versions of libc++ implement these removals for -std=c++20 and up. The hint version of the `allocate` method is optional for satisfying the allocator requirement, even as far back as C++11, so remove the `hint` parameter, not just the `hint` argument to std::allocator::allocate. base::Value needs to be a complete type in value_iterators.cc to satisfy a `requires` clause. Bug: 175635923 Test: m libchrome libmojo MODULES-IN-external-libchrome Change-Id: I28408f1f1be3e02e28187e2f8ad6ac4d20a73bd6 --- base/containers/stack_container.h | 6 +++--- base/value_iterators.cc | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/base/containers/stack_container.h b/base/containers/stack_container.h index c775744305..980da077c1 100644 --- a/base/containers/stack_container.h +++ b/base/containers/stack_container.h @@ -35,7 +35,7 @@ namespace base { template class StackAllocator : public std::allocator { public: - typedef typename std::allocator::pointer pointer; + typedef T* pointer; typedef typename std::allocator::size_type size_type; // Backing store for the allocator. The container owner is responsible for @@ -102,13 +102,13 @@ class StackAllocator : public std::allocator { // Actually do the allocation. Use the stack buffer if nobody has used it yet // and the size requested fits. Otherwise, fall through to the standard // allocator. - pointer allocate(size_type n, void* hint = 0) { + pointer allocate(size_type n) { if (source_ != NULL && !source_->used_stack_buffer_ && n <= stack_capacity) { source_->used_stack_buffer_ = true; return source_->stack_buffer(); } else { - return std::allocator::allocate(n, hint); + return std::allocator::allocate(n); } } diff --git a/base/value_iterators.cc b/base/value_iterators.cc index ba9c73072f..4765f73fdf 100644 --- a/base/value_iterators.cc +++ b/base/value_iterators.cc @@ -4,6 +4,8 @@ #include "base/value_iterators.h" +#include "base/values.h" + namespace base { namespace detail { -- cgit v1.2.3