From 3b7bd4563a0b15f850bce3b0d5eefb39d8ad8006 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 6 Feb 2018 16:32:51 +0100 Subject: [PATCH] ImVec2: added [] operator. This is becoming desirable for some types of code, better added sooner than later. --- imgui.h | 1 + 1 file changed, 1 insertion(+) diff --git a/imgui.h b/imgui.h index 5c436c02..3efc5978 100644 --- a/imgui.h +++ b/imgui.h @@ -113,6 +113,7 @@ struct ImVec2 float x, y; ImVec2() { x = y = 0.0f; } ImVec2(float _x, float _y) { x = _x; y = _y; } + float operator[] (size_t idx) const { IM_ASSERT(idx == 0 || idx == 1); return *(&x + idx); } // We very rarely use this [] operator, thus an assert is fine. #ifdef IM_VEC2_CLASS_EXTRA // Define constructor and implicit cast operators in imconfig.h to convert back<>forth from your math types and ImVec2. IM_VEC2_CLASS_EXTRA #endif