about summary refs log tree commit diff
path: root/absl/container
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2018-07-19T18·45-0700
committerAshley Hedberg <ahedberg@google.com>2018-07-20T13·18-0400
commit7aa411ceafc1272a28579cca739a97a2fb79055a (patch)
tree84f14f1a41d294a4e24428b413676ddbf3c62ab9 /absl/container
parent2c5af55ed34850d8b7dd46177c8ca53fdfda920e (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')
-rw-r--r--absl/container/inlined_vector.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/absl/container/inlined_vector.h b/absl/container/inlined_vector.h
index 75d980274a57..ca36fd3699b9 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_;