you can do it with logs as well. If you don't need the actual value (if these are intermediate computations but not the end goal for example) logs can prevent having to deal with the huge values...
But pow and log need a type that c++ understands. If these are weird big-integer or oversized floating point, it won't work.
do you allow fractional powers like pi ^ pi?
These powers are so large that you may want to keep the numbers in a split format of base and exponent, sort of like a fraction class that maintains num/denom separate?