diff options
author | couriersud <couriersud@gmx.org> | 2020-01-16 22:43:23 +0100 |
---|---|---|
committer | couriersud <couriersud@gmx.org> | 2020-01-16 22:43:23 +0100 |
commit | 09f03c4b057ce843fd417dc3a4c6d2c1b3676041 (patch) | |
tree | aeb7cdf8980b9293a7988406d49e5957f6f8664b | |
parent | 804e0e062728d2eb182b5ec6930c32a1362eb26c (diff) |
netlist: Fix building with 128bit integers. (nw)
-rw-r--r-- | src/lib/netlist/nltypes.h | 2 | ||||
-rw-r--r-- | src/lib/netlist/plib/ptime.h | 28 |
2 files changed, 19 insertions, 11 deletions
diff --git a/src/lib/netlist/nltypes.h b/src/lib/netlist/nltypes.h index 3688c41421d..ab106f9f59a 100644 --- a/src/lib/netlist/nltypes.h +++ b/src/lib/netlist/nltypes.h @@ -106,8 +106,8 @@ namespace netlist #else using netlist_time = plib::ptime<std::int64_t, NETLIST_INTERNAL_RES>; using netlist_time_ext = netlist_time; - static_assert(noexcept(netlist_time::from_nsec(1)) == true, "Not evaluated as constexpr"); #endif + static_assert(noexcept(netlist_time::from_nsec(1)) == true, "Not evaluated as constexpr"); //============================================================ // MACROS diff --git a/src/lib/netlist/plib/ptime.h b/src/lib/netlist/plib/ptime.h index 5b23271d9ff..82ee2213015 100644 --- a/src/lib/netlist/plib/ptime.h +++ b/src/lib/netlist/plib/ptime.h @@ -80,32 +80,41 @@ namespace plib m_time -= rhs.m_time; return *this; } - C14CONSTEXPR ptime &operator*=(const mult_type factor) noexcept { m_time *= static_cast<internal_type>(factor); return *this; } + + template <typename M> + C14CONSTEXPR ptime &operator*=(const M factor) noexcept + { + static_assert(plib::is_integral<M>::value, "Factor must be an integral type"); + m_time *= factor; + return *this; + } template <typename O> - friend constexpr const ptime operator-(const ptime &lhs, const ptime<O, RES> &rhs) noexcept + constexpr const ptime operator-(const ptime<O, RES> &rhs) const noexcept { static_assert(ptime_le<ptime<O, RES>, ptime>::value, "Invalid ptime type"); - return ptime(lhs.m_time - rhs.m_time); + return ptime(m_time - rhs.m_time); } template <typename O> - friend constexpr const ptime operator+(const ptime &lhs, const ptime<O, RES> &rhs) noexcept + constexpr const ptime operator+(const ptime<O, RES> &rhs) const noexcept { static_assert(ptime_le<ptime<O, RES>, ptime>::value, "Invalid ptime type"); - return ptime(lhs.m_time + rhs.m_time); + return ptime(m_time + rhs.m_time); } - friend constexpr const ptime operator*(ptime lhs, const mult_type factor) noexcept + template <typename M> + constexpr const ptime operator*(const M &factor) const noexcept { - return ptime(lhs.m_time * factor); + static_assert(plib::is_integral<M>::value, "Factor must be an integral type"); + return ptime(m_time * static_cast<mult_type>(factor)); } template <typename O> - friend constexpr mult_type operator/(const ptime lhs, const ptime<O, RES> rhs) noexcept + constexpr const mult_type operator/(const ptime<O, RES> &rhs) const noexcept { static_assert(ptime_le<ptime<O, RES>, ptime>::value, "Invalid ptime type"); - return static_cast<mult_type>(lhs.m_time / rhs.m_time); + return static_cast<mult_type>(m_time / rhs.m_time); } friend constexpr bool operator<(const ptime lhs, const ptime rhs) noexcept @@ -206,7 +215,6 @@ namespace plib internal_type m_time; }; - } // namespace plib |