mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-04 20:48:59 +00:00
Fix vector_data failure under debug (#4606)
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
b513db86c7
commit
9de0861104
@@ -51,12 +51,12 @@ inline char string_back(const std::string &value) {
|
||||
template <typename T> inline T *vector_data(std::vector<T> &vector) {
|
||||
// In some debug environments, operator[] does bounds checking, so &vector[0]
|
||||
// can't be used.
|
||||
return &(*vector.begin());
|
||||
return vector.empty() ? nullptr : &vector[0];
|
||||
}
|
||||
|
||||
template <typename T> inline const T *vector_data(
|
||||
const std::vector<T> &vector) {
|
||||
return &(*vector.begin());
|
||||
return vector.empty() ? nullptr : &vector[0];
|
||||
}
|
||||
|
||||
template <typename T, typename V>
|
||||
|
||||
Reference in New Issue
Block a user