mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-23 04:17:00 +00:00
ImVector: Added copy/assign operators as helpers to ease cloning of data.
This commit is contained in:
parent
1e296453ef
commit
6bda816ffe
4
imgui.h
4
imgui.h
@ -1120,7 +1120,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).
|
// 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).
|
||||||
// Important: Our implementation does NOT call C++ constructors/destructors. This is intentional, we do not require it but you have to be mindful of that. Do not use this class as a straight std::vector replacement in your code!
|
// *Important* Our implementation does NOT call C++ constructors/destructors. This is intentional, we do not require it but you have to be mindful of that. Do not use this class as a straight std::vector replacement in your code!
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class ImVector
|
class ImVector
|
||||||
{
|
{
|
||||||
@ -1135,6 +1135,8 @@ public:
|
|||||||
|
|
||||||
inline ImVector() { Size = Capacity = 0; Data = NULL; }
|
inline ImVector() { Size = Capacity = 0; Data = NULL; }
|
||||||
inline ~ImVector() { if (Data) ImGui::MemFree(Data); }
|
inline ~ImVector() { if (Data) ImGui::MemFree(Data); }
|
||||||
|
inline ImVector(const ImVector<T>& src) { Size = Capacity = 0; Data = NULL; operator=(src); }
|
||||||
|
inline ImVector& operator=(const ImVector<T>& src) { clear(); resize(src.Size); memcpy(Data, src.Data, (size_t)Size * sizeof(value_type)); return *this; }
|
||||||
|
|
||||||
inline bool empty() const { return Size == 0; }
|
inline bool empty() const { return Size == 0; }
|
||||||
inline int size() const { return Size; }
|
inline int size() const { return Size; }
|
||||||
|
Loading…
Reference in New Issue
Block a user