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.
This commit is contained in:
parent
9393f90ccf
commit
0101ef9fb1
|
@ -411,7 +411,7 @@ public: // conversion to basic types
|
||||||
return static_cast<int>((data_ & integer_mask) >> fractional_bits);
|
return static_cast<int>((data_ & integer_mask) >> fractional_bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr unsigned int to_uint() const {
|
constexpr unsigned int to_uint() {
|
||||||
round_up();
|
round_up();
|
||||||
return static_cast<unsigned int>((data_ & integer_mask) >> fractional_bits);
|
return static_cast<unsigned int>((data_ & integer_mask) >> fractional_bits);
|
||||||
}
|
}
|
||||||
|
@ -425,7 +425,7 @@ public: // conversion to basic types
|
||||||
return static_cast<int>((data_ & integer_mask) >> fractional_bits);
|
return static_cast<int>((data_ & integer_mask) >> fractional_bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr int64_t to_long_floor() {
|
constexpr int64_t to_long_floor() const {
|
||||||
return static_cast<int64_t>((data_ & integer_mask) >> fractional_bits);
|
return static_cast<int64_t>((data_ & integer_mask) >> fractional_bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue