From 39918487261ae814f73306dd23dc3badb5a3b21c Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 20 Oct 2015 12:37:08 +1100 Subject: [PATCH] coord: add vector relational operators --- coord/ops.hpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/coord/ops.hpp b/coord/ops.hpp index ac2686f0..5d8d5c55 100644 --- a/coord/ops.hpp +++ b/coord/ops.hpp @@ -379,6 +379,31 @@ namespace util { //------------------------------------------------------------------------- +#define VECTOR_OP(OP) \ + template < \ + size_t S, \ + typename T, \ + typename U, \ + template class A, \ + template class B \ + > \ + vector \ + operator OP (const A a, const B b) \ + { \ + vector out; \ + for (size_t i = 0; i < S; ++i) \ + out[i] = a[i] OP b[i]; \ + return out; \ + } + + VECTOR_OP(<) + VECTOR_OP(>) + VECTOR_OP(<=) + VECTOR_OP(>=) + +#undef VECTOR_OP + + #define SCALAR_OP(OP) \ template < \ size_t S, \ @@ -386,10 +411,10 @@ namespace util { typename U, \ template class K \ > \ - K \ + vector \ operator OP (const K k, const U u) \ { \ - K out; \ + vector out; \ for (size_t i = 0; i < S; ++i) \ out[i] = k[i] OP u; \ return out; \