From 4707b7e732cc35439657e985d8c9a3740a804193 Mon Sep 17 00:00:00 2001 From: Brayden Lee Date: Tue, 23 Dec 2025 14:53:22 -0500 Subject: [PATCH] Revert "Improve ImVec2 subscript helper" This reverts commit 75b044c690277bb1c2cd15c15ede4acaaf79754d. --- imgui.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imgui.h b/imgui.h index 2fd76277e..2c8fecef6 100644 --- a/imgui.h +++ b/imgui.h @@ -297,8 +297,8 @@ struct ImVec2 float x, y; constexpr ImVec2() : x(0.0f), y(0.0f) { } constexpr ImVec2(float _x, float _y) : x(_x), y(_y) { } - float& operator[] (size_t idx) { IM_ASSERT(idx == 0 || idx == 1); return idx == 0 ? x : y; } // We very rarely use this [] operator, so the assert overhead is fine. - float operator[] (size_t idx) const { IM_ASSERT(idx == 0 || idx == 1); return idx == 0 ? x : y; } + float& operator[] (size_t idx) { IM_ASSERT(idx == 0 || idx == 1); return ((float*)(void*)(char*)this)[idx]; } // We very rarely use this [] operator, so the assert overhead is fine. + float operator[] (size_t idx) const { IM_ASSERT(idx == 0 || idx == 1); return ((const float*)(const void*)(const char*)this)[idx]; } #ifdef IM_VEC2_CLASS_EXTRA IM_VEC2_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec2. #endif