blob: acb96f40d53ce5be5c67e300e22e2a52097e074d [file] [log] [blame]
Andrew Geissler8f840682023-07-21 09:09:43 -05001From 787d5052a6034cc722b073c652cc610ae037f933 Mon Sep 17 00:00:00 2001
2From: Levi Tamasi <ltamasi@fb.com>
3Date: Fri, 22 Nov 2019 18:12:35 -0800
4Subject: [PATCH 1/2] Fix the constness issues around
5 autovector::iterator_impl's dereference operators (#6057)
6
7Summary:
8As described in detail in issue https://github.com/facebook/rocksdb/issues/6048, iterators' dereference operators
9(`*`, `->`, and `[]`) should return `pointer`s/`reference`s (as opposed to
10`const_pointer`s/`const_reference`s) even if the iterator itself is `const`
11to be in sync with the standard's iterator concept.
12Pull Request resolved: https://github.com/facebook/rocksdb/pull/6057
13
14Test Plan: make check
15
16Differential Revision: D18623235
17
18Pulled By: ltamasi
19
20fbshipit-source-id: 04e82d73bc0c67fb0ded018383af8dfc332050cc
21---
22 thirdparty/rocksdb/util/autovector.h | 15 ++++-----------
23 1 file changed, 4 insertions(+), 11 deletions(-)
24
25diff --git a/thirdparty/rocksdb/util/autovector.h b/thirdparty/rocksdb/util/autovector.h
26index b5c84712..6d337908 100644
27--- a/thirdparty/rocksdb/util/autovector.h
28+++ b/thirdparty/rocksdb/util/autovector.h
29@@ -120,27 +120,20 @@ class autovector {
30 }
31
32 // -- Reference
33- reference operator*() {
34+ reference operator*() const {
35 assert(vect_->size() >= index_);
36 return (*vect_)[index_];
37 }
38
39- const_reference operator*() const {
40- assert(vect_->size() >= index_);
41- return (*vect_)[index_];
42- }
43-
44- pointer operator->() {
45+ pointer operator->() const {
46 assert(vect_->size() >= index_);
47 return &(*vect_)[index_];
48 }
49
50- const_pointer operator->() const {
51- assert(vect_->size() >= index_);
52- return &(*vect_)[index_];
53+ reference operator[](difference_type len) const {
54+ return *(*this + len);
55 }
56
57-
58 // -- Logical Operators
59 bool operator==(const self_type& other) const {
60 assert(vect_ == other.vect_);
61--
622.41.0
63