From 6172e932728a0fa629d910c1a1534d66a59e386a Mon Sep 17 00:00:00 2001 From: omar Date: Sat, 23 Dec 2017 14:49:23 +0100 Subject: [PATCH] ImVector: Added assignments and = operators + comments. --- imgui.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/imgui.h b/imgui.h index 11213d69..25c8721a 100644 --- a/imgui.h +++ b/imgui.h @@ -1005,7 +1005,7 @@ namespace ImGui //----------------------------------------------------------------------------- // Lightweight std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug). -// Our implementation does NOT call c++ constructors because we don't use them in ImGui. Don't use this class as a straight std::vector replacement in your code! +// Our implementation does NOT call C++ constructors/destructors. This is intentional and we do not require it. Do not use this class as a straight std::vector replacement in your code! template class ImVector { @@ -1020,6 +1020,8 @@ public: ImVector() { Size = Capacity = 0; Data = NULL; } ~ImVector() { if (Data) ImGui::MemFree(Data); } + ImVector(const ImVector& rhs) { Size = Capacity = 0; Data = NULL; if (rhs.Size) { resize(rhs.Size); memcpy(Data, rhs.Data, (size_t)rhs.Size * sizeof(T)); } } + ImVector& operator=(const ImVector& rhs) { resize(rhs.Size); if (rhs.Size) memcpy(Data, rhs.Data, (size_t)rhs.Size * sizeof(T)); return *this; } inline bool empty() const { return Size == 0; } inline int size() const { return Size; }