ImGuiTextBuffer: Fix size() to allow using ImGuiTextBuffer with resize(0) patterns.

This commit is contained in:
omar 2019-02-05 13:13:35 +01:00
parent f7c879eb60
commit d93e3c17fc

View File

@ -1583,7 +1583,7 @@ struct ImGuiTextBuffer
inline char operator[](int i) { IM_ASSERT(Buf.Data != NULL); return Buf.Data[i]; } inline char operator[](int i) { IM_ASSERT(Buf.Data != NULL); return Buf.Data[i]; }
const char* begin() const { return Buf.Data ? &Buf.front() : EmptyString; } const char* begin() const { return Buf.Data ? &Buf.front() : EmptyString; }
const char* end() const { return Buf.Data ? &Buf.back() : EmptyString; } // Buf is zero-terminated, so end() will point on the zero-terminator const char* end() const { return Buf.Data ? &Buf.back() : EmptyString; } // Buf is zero-terminated, so end() will point on the zero-terminator
int size() const { return Buf.Data ? Buf.Size - 1 : 0; } int size() const { return Buf.Size ? Buf.Size - 1 : 0; }
bool empty() { return Buf.Size <= 1; } bool empty() { return Buf.Size <= 1; }
void clear() { Buf.clear(); } void clear() { Buf.clear(); }
void reserve(int capacity) { Buf.reserve(capacity); } void reserve(int capacity) { Buf.reserve(capacity); }