diff --git a/include/vectorwrapper/vectorwrapper.hpp b/include/vectorwrapper/vectorwrapper.hpp index 4a4fab6..9d32032 100644 --- a/include/vectorwrapper/vectorwrapper.hpp +++ b/include/vectorwrapper/vectorwrapper.hpp @@ -414,6 +414,8 @@ namespace vwr { bool operator== ( const Vec& parLeft, const typename VectorWrapperInfo::scalar_type& parRight ); template bool operator< ( const Vec& parLeft, const typename VectorWrapperInfo::scalar_type& parRight ); + template + Vec operator- ( const Vec& parVec ); template bool operator> ( const Vec& parLeft, const T& parRight ); diff --git a/include/vectorwrapper/vectorwrapper.inl b/include/vectorwrapper/vectorwrapper.inl index 4f9da8c..85032aa 100644 --- a/include/vectorwrapper/vectorwrapper.inl +++ b/include/vectorwrapper/vectorwrapper.inl @@ -298,6 +298,12 @@ namespace vwr { typedef Vec::type> return_type; return return_type(parOp(parLeft[I], parRight[I])...); } + + template + inline + Vec unary_operator_minus (const Vec& parVec, bt::number_seq) { + return Vec(-parVec[I]...); + } } //namespace implem template const Vec Vec::unit_x(scalar_type(1)); @@ -401,6 +407,10 @@ namespace vwr { } return retval; } + template + inline Vec operator- (const Vec& parVec) { + return implem::unary_operator_minus(parVec, bt::number_range::dimensions>()); + } template inline bool operator> (const Vec& parLeft, const T& parRight) {