From 7aa411ceafc1272a28579cca739a97a2fb79055a Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 19 Jul 2018 11:45:32 -0700 Subject: Export of internal Abseil changes. -- 298d93fcb860116111611a8ab0662b409734227a by Alex Strelnikov : Release ascii_benchmark. PiperOrigin-RevId: 205275981 -- 73a01469e5862eefbe5ef9d434f45b7073476272 by Abseil Team : Internal cleanup PiperOrigin-RevId: 205236717 -- 53d6338bf49dab95bd0fbb5bbcd56970c6b868c2 by Abseil Team : Removes InlinedVector's dependency on bitwise operators for size_type PiperOrigin-RevId: 205236134 GitOrigin-RevId: 298d93fcb860116111611a8ab0662b409734227a Change-Id: I754f5eea889567add2dbbdea358a533f54a912dd --- absl/container/inlined_vector.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'absl/container') diff --git a/absl/container/inlined_vector.h b/absl/container/inlined_vector.h index 75d98027..ca36fd36 100644 --- a/absl/container/inlined_vector.h +++ b/absl/container/inlined_vector.h @@ -626,14 +626,18 @@ class InlinedVector { // It holds whether the vector is allocated or not in the lowest bit. // The size is held in the high bits: // size_ = (size << 1) | is_allocated; + // + // Maintainer's Note: size_type is user defined. The contract is limited to + // arithmetic operators to avoid depending on compliant overloaded bitwise + // operators. class Tag { public: Tag() : size_(0) {} - size_type size() const { return size_ >> 1; } - void add_size(size_type n) { size_ += n << 1; } - void set_inline_size(size_type n) { size_ = n << 1; } - void set_allocated_size(size_type n) { size_ = (n << 1) | 1; } - bool allocated() const { return size_ & 1; } + size_type size() const { return size_ / 2; } + void add_size(size_type n) { size_ += n * 2; } + void set_inline_size(size_type n) { size_ = n * 2; } + void set_allocated_size(size_type n) { size_ = (n * 2) + 1; } + bool allocated() const { return size_ % 2; } private: size_type size_; -- cgit v1.2.3