added operators +,-,*,/

This commit is contained in:
Artem Pavlenko 2006-10-16 13:32:45 +00:00
parent 1988181bd7
commit 52033ad4e8

View file

@ -27,6 +27,7 @@
#include <iomanip>
#include <sstream>
#include <boost/operators.hpp>
namespace mapnik {
template <typename T,int dim>
@ -36,6 +37,13 @@ namespace mapnik {
template <typename T>
struct coord<T,2>
: boost::addable<coord<T,2>,
boost::addable2<coord<T,2>,T,
boost::subtractable<coord<T,2>,
boost::subtractable2<coord<T,2>,T,
boost::dividable2<coord<T,2>, T,
boost::multipliable2<coord<T,2>, T > > > > > >
{
typedef T type;
T x;
@ -61,6 +69,52 @@ namespace mapnik {
y=type(rhs.y);
return *this;
}
template <typename T2>
bool operator==(coord<T2,2> const& rhs)
{
return x == rhs.x && y == rhs.y;
}
coord<T,2>& operator+=(coord<T,2> const& rhs)
{
x+=rhs.x;
y+=rhs.y;
return *this;
}
coord<T,2>& operator+=(T rhs)
{
x+=rhs;
y+=rhs;
return *this;
}
coord<T,2>& operator-=(coord<T,2> const& rhs)
{
x-=rhs.x;
y-=rhs.y;
return *this;
}
coord<T,2>& operator-=(T rhs)
{
x-=rhs;
y-=rhs;
return *this;
}
coord<T,2>& operator*=(T t)
{
x*=t;
y*=t;
return *this;
}
coord<T,2>& operator/=(T t)
{
x/=t;
y/=t;
return *this;
}
};
template <typename T>