Having these in their own separate header has always felt a bit weird. Having them as friend functions makes much more sense.
That way, each arbitrary type has its own log, pow and root function, but they're friends so you don't need to use them with the class name. This provides overloaded behaviour across the different types —i.e. there's an ipow() for Nat, Int and Rat
Note: Consider whether we want to call it ipow() in light of the fact that Rat provides rational arithmetic, so is not integer (i is short for integer).
Having these in their own separate header has always felt a bit weird. Having them as friend functions makes much more sense.
That way, each arbitrary type has its own log, pow and root function, but they're friends so you don't need to use them with the class name. This provides overloaded behaviour across the different types —i.e. there's an
ipow()
forNat
,Int
andRat
Note: Consider whether we want to call it
ipow()
in light of the fact thatRat
provides rational arithmetic, so is not integer (i is short for integer).