diff --git a/include/lol/private/math/matrix.h b/include/lol/private/math/matrix.h index d64aa2b0..743b94fd 100644 --- a/include/lol/private/math/matrix.h +++ b/include/lol/private/math/matrix.h @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2020 Sam Hocevar +// Copyright © 2010–2023 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -20,6 +20,7 @@ #include "ops.h" #include // lol::vec_t #include // std::ostream +#include // std::tuple #include // std::fabs namespace lol diff --git a/include/lol/private/math/polynomial.h b/include/lol/private/math/polynomial.h index ea05e5dc..5507747f 100644 --- a/include/lol/private/math/polynomial.h +++ b/include/lol/private/math/polynomial.h @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2020 Sam Hocevar +// Copyright © 2010–2023 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -27,6 +27,7 @@ #include // std::tuple #include // assert() #include // sqrt(), cbrt(), acos() +#include // std::size_t namespace lol { @@ -265,13 +266,13 @@ struct [[nodiscard]] polynomial return {}; } - /* Access individual coefficients. This is read-only and returns a - * copy because we cannot let the user mess with the integrity of - * the structure (i.e. the guarantee that the leading coefficient - * remains non-zero). */ - [[nodiscard]] inline T operator[](ptrdiff_t n) const + // Access individual coefficients. This is read-only and returns a + // copy because we cannot let the user mess with the integrity of + // the structure (i.e. the guarantee that the leading coefficient + // remains non-zero). + [[nodiscard]] inline T operator[](std::size_t n) const { - if (n < 0 || n > degree()) + if (degree() < 0 || n > std::size_t(degree())) return T(0); return m_coefficients[n]; diff --git a/include/lol/private/math/vector.h b/include/lol/private/math/vector.h index 3edda74f..deb7742c 100644 --- a/include/lol/private/math/vector.h +++ b/include/lol/private/math/vector.h @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010—2020 Sam Hocevar +// Copyright © 2010–2023 Sam Hocevar // // Lol Engine is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -103,8 +103,9 @@ private: */ #define LOL_COMMON_MEMBER_OPS(first) \ - inline T& operator[](size_t n) { return (&this->first)[n]; } \ - inline T const& operator[](size_t n) const { return (&this->first)[n]; } \ + /* Use reinterpret_cast because static_cast is illegal here */ \ + inline T& operator[](size_t n) { return reinterpret_cast(this)[n]; } \ + inline T const& operator[](size_t n) const { return reinterpret_cast(this)[n]; } \ \ /* An explicit assignment operator is now mandatory */ \ inline type & operator =(type const &that) \