diff --git a/include/mcpp/util.h b/include/mcpp/util.h index e503b43..ae36fd6 100644 --- a/include/mcpp/util.h +++ b/include/mcpp/util.h @@ -19,11 +19,16 @@ struct Coordinate { /** * @brief Constructs a Coordinate object with integer values. * - * @param x The x-coordinate. Default is 0. - * @param y The y-coordinate. Default is 0. - * @param z The z-coordinate. Default is 0. + * @param x The x-coordinate. + * @param y The y-coordinate. + * @param z The z-coordinate. */ - explicit Coordinate(int x = 0, int y = 0, int z = 0); + constexpr Coordinate(int x, int y, int z) : x(x), y(y), z(z) {} + + /** + * @brief Constructs a Coordinate object with zero values. + */ + constexpr Coordinate() : x(0), y(0), z(0) {} /** * @brief Constructs a Coordinate object with double values. @@ -32,7 +37,9 @@ struct Coordinate { * @param y The y-coordinate as a double. * @param z The z-coordinate as a double. */ - Coordinate(double x, double y, double z); + constexpr Coordinate(double x, double y, double z) + : x(static_cast(x)), y(static_cast(y)), + z(static_cast(z)) {} /** * @brief Adds two Coordinate objects. diff --git a/src/util.cpp b/src/util.cpp index f52aa55..bf82f7c 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -5,18 +5,6 @@ namespace mcpp { -Coordinate::Coordinate(int x, int y, int z) { - this->x = x; - this->y = y; - this->z = z; -} - -Coordinate::Coordinate(double x, double y, double z) { - this->x = static_cast(x); - this->y = static_cast(y); - this->z = static_cast(z); -} - Coordinate Coordinate::operator+(const Coordinate& obj) const { Coordinate result; result.x = this->x + obj.x;