diff options
Diffstat (limited to 'absl/container')
-rw-r--r-- | absl/container/BUILD.bazel | 2 | ||||
-rw-r--r-- | absl/container/inlined_vector.h | 76 | ||||
-rw-r--r-- | absl/container/internal/hashtable_debug.h | 2 | ||||
-rw-r--r-- | absl/container/internal/raw_hash_set.h | 2 |
4 files changed, 41 insertions, 41 deletions
diff --git a/absl/container/BUILD.bazel b/absl/container/BUILD.bazel index afc869f45aac..d0789923c34e 100644 --- a/absl/container/BUILD.bazel +++ b/absl/container/BUILD.bazel @@ -15,7 +15,7 @@ # load( - "//absl:copts.bzl", + "//absl:copts/configure_copts.bzl", "ABSL_DEFAULT_COPTS", "ABSL_TEST_COPTS", "ABSL_EXCEPTIONS_FLAG", diff --git a/absl/container/inlined_vector.h b/absl/container/inlined_vector.h index 5f3f0095bca8..d044e31c25ad 100644 --- a/absl/container/inlined_vector.h +++ b/absl/container/inlined_vector.h @@ -774,6 +774,39 @@ class InlinedVector { bool allocated() const { return tag().allocated(); } + void ResetAllocation(Allocation new_allocation, size_type new_size) { + if (allocated()) { + Destroy(allocated_space(), allocated_space() + size()); + assert(begin() == allocated_space()); + allocation().Dealloc(allocator()); + allocation() = new_allocation; + } else { + Destroy(inlined_space(), inlined_space() + size()); + init_allocation(new_allocation); // bug: only init once + } + tag().set_allocated_size(new_size); + } + + template <typename... Args> + reference Construct(pointer p, Args&&... args) { + std::allocator_traits<allocator_type>::construct( + allocator(), p, std::forward<Args>(args)...); + return *p; + } + + template <typename Iterator> + void UninitializedCopy(Iterator src, Iterator src_last, pointer dst) { + for (; src != src_last; ++dst, ++src) Construct(dst, *src); + } + + template <typename... Args> + void UninitializedFill(pointer dst, pointer dst_last, const Args&... args) { + for (; dst != dst_last; ++dst) Construct(dst, args...); + } + + // Destroy [`from`, `to`) in place. + void Destroy(pointer from, pointer to); + // Enlarge the underlying representation so we can store `size_ + delta` elems // in allocated space. The size is not changed, and any newly added memory is // not initialized. @@ -790,19 +823,6 @@ class InlinedVector { std::pair<iterator, iterator> ShiftRight(const_iterator position, size_type n); - void ResetAllocation(Allocation new_allocation, size_type new_size) { - if (allocated()) { - Destroy(allocated_space(), allocated_space() + size()); - assert(begin() == allocated_space()); - allocation().Dealloc(allocator()); - allocation() = new_allocation; - } else { - Destroy(inlined_space(), inlined_space() + size()); - init_allocation(new_allocation); // bug: only init once - } - tag().set_allocated_size(new_size); - } - template <typename... Args> reference GrowAndEmplaceBack(Args&&... args) { assert(size() == capacity()); @@ -825,25 +845,11 @@ class InlinedVector { void InitAssign(size_type n, const_reference v); - template <typename... Args> - reference Construct(pointer p, Args&&... args) { - std::allocator_traits<allocator_type>::construct( - allocator(), p, std::forward<Args>(args)...); - return *p; - } - template <typename Iterator> - void UninitializedCopy(Iterator src, Iterator src_last, pointer dst) { - for (; src != src_last; ++dst, ++src) Construct(dst, *src); - } - - template <typename... Args> - void UninitializedFill(pointer dst, pointer dst_last, const Args&... args) { - for (; dst != dst_last; ++dst) Construct(dst, args...); - } + void AssignRange(Iterator first, Iterator last, std::forward_iterator_tag); - // Destroy [`from`, `to`) in place. - void Destroy(pointer from, pointer to); + template <typename Iterator> + void AssignRange(Iterator first, Iterator last, std::input_iterator_tag); template <typename Iterator> void AppendRange(Iterator first, Iterator last, std::forward_iterator_tag); @@ -851,12 +857,6 @@ class InlinedVector { template <typename Iterator> void AppendRange(Iterator first, Iterator last, std::input_iterator_tag); - template <typename Iterator> - void AssignRange(Iterator first, Iterator last, std::forward_iterator_tag); - - template <typename Iterator> - void AssignRange(Iterator first, Iterator last, std::input_iterator_tag); - iterator InsertWithCount(const_iterator position, size_type n, const_reference v); @@ -1244,7 +1244,7 @@ void InlinedVector<T, N, A>::EnlargeBy(size_type delta) { const size_type s = size(); assert(s <= capacity()); - size_type target = std::max(inlined_capacity(), s + delta); + size_type target = (std::max)(inlined_capacity(), s + delta); // Compute new capacity by repeatedly doubling current capacity // TODO(psrc): Check and avoid overflow? @@ -1299,7 +1299,7 @@ auto InlinedVector<T, N, A>::ShiftRight(const_iterator position, size_type n) iterator pos = const_cast<iterator>(position); iterator raw_space = end(); size_type slots_in_used_space = raw_space - pos; - size_type new_elements_in_used_space = std::min(n, slots_in_used_space); + size_type new_elements_in_used_space = (std::min)(n, slots_in_used_space); size_type new_elements_in_raw_space = n - new_elements_in_used_space; size_type old_elements_in_used_space = slots_in_used_space - new_elements_in_used_space; diff --git a/absl/container/internal/hashtable_debug.h b/absl/container/internal/hashtable_debug.h index c3bd65c9c4ec..38050c69f61f 100644 --- a/absl/container/internal/hashtable_debug.h +++ b/absl/container/internal/hashtable_debug.h @@ -60,7 +60,7 @@ std::vector<size_t> GetHashtableDebugNumProbesHistogram(const C& container) { size_t num_probes = GetHashtableDebugNumProbes( container, absl::container_internal::hashtable_debug_internal::GetKey<C>(*it, 0)); - v.resize(std::max(v.size(), num_probes + 1)); + v.resize((std::max)(v.size(), num_probes + 1)); v[num_probes]++; } return v; diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h index 575f1b007b44..029540d8d985 100644 --- a/absl/container/internal/raw_hash_set.h +++ b/absl/container/internal/raw_hash_set.h @@ -1363,7 +1363,7 @@ class raw_hash_set { void rehash(size_t n) { if (n == 0 && capacity_ == 0) return; if (n == 0 && size_ == 0) return destroy_slots(); - auto m = NormalizeCapacity(std::max(n, NumSlotsFast(size()))); + auto m = NormalizeCapacity((std::max)(n, NumSlotsFast(size()))); // n == 0 unconditionally rehashes as per the standard. if (n == 0 || m > capacity_) { resize(m); |