Only apply divide by zero protection to integers

Also allow arithmetic error to bubble up to the caller.
This commit is contained in:
Jason Turner
2015-01-09 20:06:04 -07:00
parent 8746a9eea5
commit 25b15a3449
3 changed files with 12 additions and 4 deletions

View File

@@ -53,7 +53,9 @@ namespace chaiscript
template<typename T>
static void check_divide_by_zero(T t)
{
if(std::is_arithmetic<T>::value) if(t==0) throw chaiscript::exception::arithmetic_error("divide by zero");
if(std::is_integral<T>::value && std::is_arithmetic<T>::value && t==0) {
throw chaiscript::exception::arithmetic_error("divide by zero");
}
}
#else
template<typename T>