restrict implicit constructor
This commit is contained in:
parent
f77b8e5c41
commit
ad4da95ca1
@ -45,8 +45,9 @@ class wrapped_int
|
|||||||
wrapped_int() = default;
|
wrapped_int() = default;
|
||||||
explicit wrapped_int(T val) : m_val(val) {}
|
explicit wrapped_int(T val) : m_val(val) {}
|
||||||
|
|
||||||
// allow implicit conversions from anything that `T` allows conversions from
|
// 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>::type>
|
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) {}
|
wrapped_int(T2 val) : m_val(val) {}
|
||||||
|
|
||||||
bool operator==(const wrapped_int& other) const
|
bool operator==(const wrapped_int& other) const
|
||||||
@ -67,7 +68,7 @@ class wrapped_int
|
|||||||
}
|
}
|
||||||
wrapped_int& operator/=(const wrapped_int& other)
|
wrapped_int& operator/=(const wrapped_int& other)
|
||||||
{
|
{
|
||||||
val /= static_cast<T>(other);
|
m_val /= static_cast<T>(other);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
bool operator<(const wrapped_int& other) const
|
bool operator<(const wrapped_int& other) const
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user