Making a Universal Vector2 Type in C++ - Part 1: Library User Perspective
The Interoperability Problem When using multiple libraries in your project, a quite frequent source of annoyance is trying to share their fundamental types, such as a two dimensional vector, quaternion, euler angle, etc. In each library, you can find various names for exactly the same concept. Consider a hypothetical game development scenario: you could be using Box2D for physics (which has b2Vec2), raylib for graphics (which has Vector2). Despite that two types represent exactly the same thing, they cannot be used interchangeably. This forces you to copy one object into another, every time you wish to pass data and convert between them. Since these conversions are needed quite frequently, constantly operating on copies can become a source of bugs, along with being generally unergonomic. What if we could make our own type to rule them all? ...