struct IsNegative<T, false>
{ static bool eval(T) { return false; } };
+template<typename T, bool f = is_signed<T>::value>
+struct Negate
+{ static T eval(T v) { return -v; } };
+
+template<typename T>
+struct Negate<T, false>
+{ static T eval(T v) { return (~v)+1; } };
+
/* Helper to avoid errors about ambiguous function calls since there are no
overloads of abs for unsigned types */
template<typename T, bool f = is_signed<T>::value>
}
if(neg)
- result = -result;
+ result = Negate<T>::eval(result);
return result;
}
result += atom;
}
result += ND_JUMP;
- write_int<Offset>(-(atom.size()+jump_size), result);
+ write_int<Offset>(-static_cast<Offset>(atom.size()+jump_size), result);
}
else if(repeat_max>repeat_min)
{