coord/ops: don't use multiplication for negation

This commit is contained in:
Danny Robson 2015-10-19 12:04:39 +11:00
parent 5ed95ec952
commit 634f2af9cc

View File

@ -171,10 +171,20 @@ namespace util {
//-------------------------------------------------------------------------
// negation
template <size_t S, typename T, template<size_t,typename> class K>
K<S,T> operator- (K<S,T> k)
template <
size_t S,
typename T,
template<size_t,typename> class K
>
typename std::enable_if<
std::is_signed<T>::value,
K<S,T>
>::type
operator- (K<S,T> k)
{
return k * T{-1};
for (auto &v: k)
v = -v;
return k;
}