diff options
author | 2018-07-19 11:45:32 -0700 | |
---|---|---|
committer | 2018-07-20 09:18:23 -0400 | |
commit | 7aa411ceafc1272a28579cca739a97a2fb79055a (patch) | |
tree | 84f14f1a41d294a4e24428b413676ddbf3c62ab9 /absl/container/inlined_vector.h | |
parent | 2c5af55ed34850d8b7dd46177c8ca53fdfda920e (diff) |
Export of internal Abseil changes.
--
298d93fcb860116111611a8ab0662b409734227a by Alex Strelnikov <strel@google.com>:
Release ascii_benchmark.
PiperOrigin-RevId: 205275981
--
73a01469e5862eefbe5ef9d434f45b7073476272 by Abseil Team <absl-team@google.com>:
Internal cleanup
PiperOrigin-RevId: 205236717
--
53d6338bf49dab95bd0fbb5bbcd56970c6b868c2 by Abseil Team <absl-team@google.com>:
Removes InlinedVector's dependency on bitwise operators for size_type
PiperOrigin-RevId: 205236134
GitOrigin-RevId: 298d93fcb860116111611a8ab0662b409734227a
Change-Id: I754f5eea889567add2dbbdea358a533f54a912dd
Diffstat (limited to 'absl/container/inlined_vector.h')
-rw-r--r-- | absl/container/inlined_vector.h | 14 |
1 files changed, 9 insertions, 5 deletions
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_; |