Casting away const and then modifying the object is UB if the original object was const.
From cppreference:
"Modifying a const object through a non-const access path results in undefined behavior."
We fix the problem by making mpq and state mutable, as we can change the inner representaton in certain circumstances without changing the rational value represented by the object.
Casting away const and then modifying the object is UB if the original object was const. From cppreference: "Modifying a const object through a non-const access path results in undefined behavior."
We fix the problem by making
mpq
andstate
mutable, as we can change the inner representaton in certain circumstances without changing the rational value represented by the object.Fixes #662.