From 0101ef9fb115e59f1b9b7a28890104b115eb184d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 18 Oct 2022 13:05:08 -0400 Subject: fixed_point: Make to_uint() non-const This calls round_up(), which is a non-const member function, so if a fixed-point instantiation ever calls to_uint(), it'll result in a compiler error. This allows the member function to work. While we're at it, we can actually mark to_long_floor() as const, since it's not modifying any member state. --- src/common/fixed_point.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/fixed_point.h b/src/common/fixed_point.h index 7f00dd7b5..116dfbb33 100644 --- a/src/common/fixed_point.h +++ b/src/common/fixed_point.h @@ -411,7 +411,7 @@ public: // conversion to basic types return static_cast((data_ & integer_mask) >> fractional_bits); } - constexpr unsigned int to_uint() const { + constexpr unsigned int to_uint() { round_up(); return static_cast((data_ & integer_mask) >> fractional_bits); } @@ -425,7 +425,7 @@ public: // conversion to basic types return static_cast((data_ & integer_mask) >> fractional_bits); } - constexpr int64_t to_long_floor() { + constexpr int64_t to_long_floor() const { return static_cast((data_ & integer_mask) >> fractional_bits); } -- cgit v1.2.3