diff options
Diffstat (limited to 'src/lib/netlist/plib/putil.h')
-rw-r--r-- | src/lib/netlist/plib/putil.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/lib/netlist/plib/putil.h b/src/lib/netlist/plib/putil.h index 9a21a223ba9..ae358b960df 100644 --- a/src/lib/netlist/plib/putil.h +++ b/src/lib/netlist/plib/putil.h @@ -259,6 +259,19 @@ namespace plib static inline constexpr const T cast(V &&v) noexcept { return static_cast<T>(v); } }; + /*! typesafe reciprocal function + * + * @tparam T type of the argument + * @param v argument + * @return reciprocal of argument + */ + template <typename T> + static inline constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type + reciprocal(T v) noexcept + { + return constants<T>::one() / v; + } + static_assert(noexcept(constants<double>::one()) == true, "Not evaluated as constexpr"); |