point: add a cast method

This commit is contained in:
Danny Robson 2015-01-19 13:26:33 +11:00
parent d3f098216c
commit 2210db9c4e
2 changed files with 16 additions and 0 deletions

View File

@ -63,6 +63,8 @@ namespace util {
static const point<S,T> ORIGIN; static const point<S,T> ORIGIN;
template<typename U> point<S,U> cast (void) const;
void sanity (void) const; void sanity (void) const;
}; };

View File

@ -93,4 +93,18 @@ namespace util {
out.data + L1); out.data + L1);
return out; return out;
} }
//-------------------------------------------------------------------------
template <size_t S, typename T>
template <typename U>
point<S,U>
point<S,T>::cast (void) const
{
point<S,U> out;
std::copy (std::begin (this->data),
std::end (this->data),
std::begin (out.data));
return out;
}
} }