From b411a731fef9af1c0a73e4d5b718e5a6b12af1c2 Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Wed, 19 Jan 2022 19:46:17 +0000 Subject: Add nodiscard to core math classes to catch c++ errors. A common source of errors is to call functions (such as round()) expecting them to work in place, but them actually being designed only to return the processed value. Not using the return value in this case in indicative of a bug, and can be flagged as a warning by using the [[nodiscard]] attribute. --- core/math/vector2.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/math/vector2.h') diff --git a/core/math/vector2.h b/core/math/vector2.h index a340036ac7..af40b9e68d 100644 --- a/core/math/vector2.h +++ b/core/math/vector2.h @@ -36,7 +36,7 @@ struct Vector2i; -struct Vector2 { +struct _NO_DISCARD_ Vector2 { static const int AXIS_COUNT = 2; enum Axis { @@ -284,7 +284,7 @@ typedef Vector2 Point2; /* INTEGER STUFF */ -struct Vector2i { +struct _NO_DISCARD_ Vector2i { enum Axis { AXIS_X, AXIS_Y, -- cgit v1.2.3