point: add self-division operator

This commit is contained in:
Danny Robson 2015-02-19 13:18:28 +11:00
parent 38d3fc1961
commit 60f2a7e00d
2 changed files with 14 additions and 0 deletions

View File

@ -53,6 +53,19 @@ util::point<S,T>::operator* (T f) const {
} }
//-----------------------------------------------------------------------------
template <size_t S, typename T>
util::point<S,T>&
util::point<S,T>::operator/= (T f)
{
std::transform (std::begin (this->data),
std::end (this->data),
std::begin (this->data),
[f] (auto i) { return i / f; });
return *this;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <size_t S, typename T> template <size_t S, typename T>
util::point<S,T> util::point<S,T>

View File

@ -44,6 +44,7 @@ namespace util {
// arithetic operators // arithetic operators
point<S,T>& operator*= (T); point<S,T>& operator*= (T);
point<S,T> operator* (T) const; point<S,T> operator* (T) const;
point<S,T>& operator/= (T);
point<S,T> operator/ (T) const; point<S,T> operator/ (T) const;
vector<S,T> operator- (const point<S,T>&) const; vector<S,T> operator- (const point<S,T>&) const;