summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/plib/pstonum.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/netlist/plib/pstonum.h')
-rw-r--r--src/lib/netlist/plib/pstonum.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/lib/netlist/plib/pstonum.h b/src/lib/netlist/plib/pstonum.h
index 630dee68422..c4bf692d177 100644
--- a/src/lib/netlist/plib/pstonum.h
+++ b/src/lib/netlist/plib/pstonum.h
@@ -10,6 +10,7 @@
#include "pconfig.h"
#include "pexception.h"
+#include "pgsl.h"
#include "pmath.h" // for pstonum
#include "pstring.h"
@@ -36,9 +37,9 @@ namespace plib
if (ss >> x)
{
auto pos(ss.tellg());
- if (pos == static_cast<decltype(pos)>(-1))
+ if (pos == decltype(pos)(-1))
pos = len;
- *idx = static_cast<std::size_t>(pos);
+ *idx = narrow_cast<std::size_t>(pos);
}
else
*idx = constants<std::size_t>::zero();
@@ -88,7 +89,7 @@ namespace plib
template <typename S>
FLOAT128 operator()(std::locale loc, const S &arg, std::size_t *idx)
{
- return static_cast<FLOAT128>(pstonum_locale<long double>(loc, arg, idx));
+ return narrow_cast<FLOAT128>(pstonum_locale<long double>(loc, arg, idx));
}
};
#endif
@@ -100,8 +101,8 @@ namespace plib
std::size_t idx(0);
auto ret = pstonum_helper<T>()(loc, cstr, &idx);
using ret_type = decltype(ret);
- if (ret >= static_cast<ret_type>(plib::numeric_limits<T>::lowest())
- && ret <= static_cast<ret_type>(plib::numeric_limits<T>::max()))
+ if (ret >= narrow_cast<ret_type>(plib::numeric_limits<T>::lowest())
+ && ret <= narrow_cast<ret_type>(plib::numeric_limits<T>::max()))
{
if (cstr[idx] != 0)
throw pexception(pstring("Continuation after numeric value ends: ") + pstring(cstr));
@@ -110,7 +111,7 @@ namespace plib
{
throw pexception(pstring("Out of range: ") + pstring(cstr));
}
- return static_cast<T>(ret);
+ return narrow_cast<T>(ret);
}
template<typename R, typename T>