From 1b19dadd404c80cdfff79df7e6f95057428cfd8c Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 21 Jan 2015 23:38:09 +1100 Subject: [PATCH] point: add free multiply operator --- point.cpp | 6 ++++++ point.hpp | 1 + 2 files changed, 7 insertions(+) diff --git a/point.cpp b/point.cpp index 36c2c1c2..f510a5ce 100644 --- a/point.cpp +++ b/point.cpp @@ -178,6 +178,11 @@ util::operator* (const point &p, const vector &v) { return v * p; } +//----------------------------------------------------------------------------- +template +util::point +util::operator* (T a, const point &b) + { return b * a; } //----------------------------------------------------------------------------- @@ -201,6 +206,7 @@ template struct util::point; template std::ostream& util::operator<< (std::ostream &os, const util::point&); \ template util::point util::operator* (const point&, const vector&); \ template util::point util::operator* (const vector&, const point&); \ +template util::point util::operator* (T, const point&); #define INSTANTIATE(T) \ INSTANTIATE_S_T(1,T) \ diff --git a/point.hpp b/point.hpp index 7c304cae..f12be728 100644 --- a/point.hpp +++ b/point.hpp @@ -69,6 +69,7 @@ namespace util { // free maths operators template point operator* (const vector&, const point&); template point operator* (const point&, const vector&); + template point operator* (T, const point&); // iostream operators template