restrict implicit constructor

This commit is contained in:
Eric Wieser 2022-07-13 06:53:14 +00:00
parent f77b8e5c41
commit ad4da95ca1

View File

@ -45,8 +45,9 @@ class wrapped_int
wrapped_int() = default;
explicit wrapped_int(T val) : m_val(val) {}
// allow implicit conversions from anything that `T` allows conversions from
template<typename T2, typename = typename std::enable_if<std::is_convertible<T2, T>::value>::type>
// allow implicit conversions from any builtin types that `T` allows conversions from
template<typename T2,
typename = typename std::enable_if<std::is_convertible<T2, T>::value && std::is_arithmetic<T2>::value>::type>
wrapped_int(T2 val) : m_val(val) {}
bool operator==(const wrapped_int& other) const
@ -67,7 +68,7 @@ class wrapped_int
}
wrapped_int& operator/=(const wrapped_int& other)
{
val /= static_cast<T>(other);
m_val /= static_cast<T>(other);
return *this;
}
bool operator<(const wrapped_int& other) const