Implement unary operator-

This commit is contained in:
King_DuckZ 2017-01-26 17:26:26 +00:00
parent 2f4d319675
commit 780e6647b2
2 changed files with 12 additions and 0 deletions

View file

@ -414,6 +414,8 @@ namespace vwr {
bool operator== ( const Vec<V>& parLeft, const typename VectorWrapperInfo<V>::scalar_type& parRight );
template <typename V>
bool operator< ( const Vec<V>& parLeft, const typename VectorWrapperInfo<V>::scalar_type& parRight );
template <typename V>
Vec<V> operator- ( const Vec<V>& parVec );
template <typename V1, typename T>
bool operator> ( const Vec<V1>& parLeft, const T& parRight );

View file

@ -298,6 +298,12 @@ namespace vwr {
typedef Vec<typename std::common_type<V1, V2>::type> return_type;
return return_type(parOp(parLeft[I], parRight[I])...);
}
template <typename V, size_type... I>
inline
Vec<V> unary_operator_minus (const Vec<V>& parVec, bt::number_seq<size_type, I...>) {
return Vec<V>(-parVec[I]...);
}
} //namespace implem
template <typename V> const Vec<V, 1> Vec<V, 1>::unit_x(scalar_type(1));
@ -401,6 +407,10 @@ namespace vwr {
}
return retval;
}
template <typename V>
inline Vec<V> operator- (const Vec<V>& parVec) {
return implem::unary_operator_minus(parVec, bt::number_range<size_type, 0, VectorWrapperInfo<V>::dimensions>());
}
template <typename V1, typename T>
inline bool operator> (const Vec<V1>& parLeft, const T& parRight) {