Commit 9de08611 authored by vglavnyy's avatar vglavnyy Committed by Wouter van Oortmerssen

Fix vector_data failure under debug (#4606)

parent b513db86
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment