diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h index e08e96118..2c3398bd2 100644 --- a/include/flatbuffers/flatbuffers.h +++ b/include/flatbuffers/flatbuffers.h @@ -1117,14 +1117,14 @@ FLATBUFFERS_FINAL_CLASS bool force_defaults_; // Serialize values equal to their defaults anyway. struct StringOffsetCompare { - StringOffsetCompare(const vector_downward &buf) : buf_(buf) {} + StringOffsetCompare(const vector_downward &buf) : buf_(&buf) {} bool operator() (const Offset &a, const Offset &b) const { - auto stra = reinterpret_cast(buf_.data_at(a.o)); - auto strb = reinterpret_cast(buf_.data_at(b.o)); + auto stra = reinterpret_cast(buf_->data_at(a.o)); + auto strb = reinterpret_cast(buf_->data_at(b.o)); return strncmp(stra->c_str(), strb->c_str(), std::min(stra->size(), strb->size()) + 1) < 0; } - const vector_downward &buf_; + const vector_downward *buf_; }; // For use with CreateSharedString. Instantiated on first use only.