From 108c10883a03448957c1269177c38d13b5edcba8 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Sun, 23 Mar 2014 22:07:01 +0100 Subject: [PATCH] Support for unary minus operator. --- src/vector.hpp | 3 +++ src/vector.inl | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/vector.hpp b/src/vector.hpp index a649080..41dd2b8 100644 --- a/src/vector.hpp +++ b/src/vector.hpp @@ -105,6 +105,9 @@ namespace cloonel { template bool operator!= ( const Vector& parA, const Vector& parB ) __attribute__((pure)); + template + Vector operator- ( Vector parOperand ) __attribute__((pure)); + typedef Vector float2; typedef Vector ushort2; typedef Vector int2; diff --git a/src/vector.inl b/src/vector.inl index 98e3d12..2059621 100644 --- a/src/vector.inl +++ b/src/vector.inl @@ -245,4 +245,12 @@ namespace cloonel { } return retVal; } + + template + Vector operator- (Vector parOperand) { + for (uint32_t z = 0; z < S; ++z) { + parOperand[z] = -parOperand[z]; + } + return parOperand; + } } //namespace cloonel