From 15ba4d6c4bd965c23f90987383e5a072fc419ce7 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Mon, 22 May 2017 10:53:11 -0700 Subject: [PATCH] Address MS Visual Studio 2017 issue with autovector Summary: This addresses https://github.com/facebook/rocksdb/issues/2262 Closes https://github.com/facebook/rocksdb/pull/2333 Differential Revision: D5097941 Pulled By: siying fbshipit-source-id: fb33582bfe7883ecc3f6da028703982522b5f75f --- util/autovector.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/util/autovector.h b/util/autovector.h index d9f9ee3fc..48635a95b 100644 --- a/util/autovector.h +++ b/util/autovector.h @@ -98,16 +98,16 @@ class autovector { return old; } - self_type operator-(difference_type len) { + self_type operator-(difference_type len) const { return self_type(vect_, index_ - len); } - difference_type operator-(const self_type& other) { + difference_type operator-(const self_type& other) const { assert(vect_ == other.vect_); return index_ - other.index_; } - self_type operator+(difference_type len) { + self_type operator+(difference_type len) const { return self_type(vect_, index_ + len); } @@ -126,11 +126,23 @@ class autovector { assert(vect_->size() >= index_); return (*vect_)[index_]; } + + const_reference operator*() const { + assert(vect_->size() >= index_); + return (*vect_)[index_]; + } + pointer operator->() { assert(vect_->size() >= index_); return &(*vect_)[index_]; } + const_pointer operator->() const { + assert(vect_->size() >= index_); + return &(*vect_)[index_]; + } + + // -- Logical Operators bool operator==(const self_type& other) const { assert(vect_ == other.vect_);