T Chusov::Math::MultiplicativeInverse | ( | const T & | x | ) |
A helper function that calculates a multiplicative inversion of a given value of a given type and returns the result.
T | is a type of an object to be multiplicatively inverted. See remarks to the requirements for the type. |
x | is an object to be inverted. |
If the type T
is a class type which defines the method MultiplicativeInverse
which, if applied to a const-qualified object of the type T
, yields a new object of the type T
, then the function simply calls that method and returns the result.
Otherwise, if the expression
, where x
is a value of type the T
which is not an additive identity of T
, is well-formed, the function evaluates the result of the expression and returns it as-is. This covers the cases for all C++ fundamental arithmetic types, for which std::is_arithmetic <T>::value is true.