[nostalgia/geo] Fix Vec2 test
This commit is contained in:
		| @@ -8,11 +8,9 @@ | |||||||
|  |  | ||||||
| namespace nostalgia::geo { | namespace nostalgia::geo { | ||||||
|  |  | ||||||
| #ifndef OX_OS_BareMetal // doesn't compile in devKitPro for some reason |  | ||||||
| static_assert([] { | static_assert([] { | ||||||
| 	Vec2 v(1, 2); | 	Vec2 v(1, 2); | ||||||
| 	return v.x == 1 && v.y == 2 && v[0] == 1 && v[1] == 2 && v.size() == 2; | 	return v.x == 1 && v.y == 2 && v[0] == 1 && v[1] == 2 && v.size() == 2; | ||||||
| }); | }()); | ||||||
| #endif |  | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -9,6 +9,7 @@ | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #include <ox/model/def.hpp> | #include <ox/model/def.hpp> | ||||||
|  | #include <ox/std/assert.hpp> | ||||||
| #include <ox/std/bit.hpp> | #include <ox/std/bit.hpp> | ||||||
| #include <ox/std/def.hpp> | #include <ox/std/def.hpp> | ||||||
| #include <ox/std/error.hpp> | #include <ox/std/error.hpp> | ||||||
| @@ -192,11 +193,35 @@ struct Vec { | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		constexpr auto &operator[](std::size_t i) noexcept { | 		constexpr auto &operator[](std::size_t i) noexcept { | ||||||
| 			return start()[i]; | 			if (std::is_constant_evaluated()) { | ||||||
|  | 				switch (i) { | ||||||
|  | 					case 0: | ||||||
|  | 						return x; | ||||||
|  | 					case 1: | ||||||
|  | 						return y; | ||||||
|  | 					default: | ||||||
|  | 						oxAssert(false, "Read past end of Vec2"); | ||||||
|  | 						return y; | ||||||
|  | 				} | ||||||
|  | 			} else { | ||||||
|  | 				return start()[i]; | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		constexpr const auto &operator[](std::size_t i) const noexcept { | 		constexpr const auto &operator[](std::size_t i) const noexcept { | ||||||
| 			return start()[i]; | 			if (std::is_constant_evaluated()) { | ||||||
|  | 				switch (i) { | ||||||
|  | 					case 0: | ||||||
|  | 						return x; | ||||||
|  | 					case 1: | ||||||
|  | 						return y; | ||||||
|  | 					default: | ||||||
|  | 						oxAssert(false, "Read past end of Vec2"); | ||||||
|  | 						return y; | ||||||
|  | 				} | ||||||
|  | 			} else { | ||||||
|  | 				return start()[i]; | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		constexpr auto operator==(const Vec &v) const noexcept { | 		constexpr auto operator==(const Vec &v) const noexcept { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user