Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enough with the unsigned integers #124

Open
Heraclius opened this issue Apr 22, 2023 · 0 comments
Open

Enough with the unsigned integers #124

Heraclius opened this issue Apr 22, 2023 · 0 comments

Comments

@Heraclius
Copy link

I noticed this library makes liberal use of unsigned integers, both in their raw form (e.g. std::uint32_t) and as part of tmx::Vector2u.

As a rule, unless you're doing bitwise operations or explicitly need wrapping behavior, unsigned integers should really be avoided. There are many articles online discussing the reasons why. They provide little to no protection against putting negative values where they don't belong, and instead open the door to a lot of weird bugs. There is a reason why the larger C++ world is slowly moving away from unsigned integers, and even added ssize (signed size) to the standard library in C++20.

It's really annoying trying to use this library with my own code and having to static_cast everything I pass or receive from it. It's doubly annoying when it doesn't come with any built-in conversions between Vector2i and Vector2u (or Vector2f). I skimmed through the source code and found nothing in there that actually requires the use of unsigned integers. They should really all be replaced with regular ints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant