point: add redim with constant

This commit is contained in:
Danny Robson 2015-02-19 13:19:02 +11:00
parent 60f2a7e00d
commit 049aaf84c9
2 changed files with 17 additions and 0 deletions

View File

@ -59,6 +59,7 @@ namespace util {
template <size_t D> point<D,T> redim (void) const; template <size_t D> point<D,T> redim (void) const;
template <size_t D> point<D,T> redim (const util::point<D,T> &fill) const; template <size_t D> point<D,T> redim (const util::point<D,T> &fill) const;
template <size_t D> point<D,T> redim (T fill) const;
static const point<S,T> ORIGIN; static const point<S,T> ORIGIN;

View File

@ -95,6 +95,22 @@ namespace util {
} }
//-------------------------------------------------------------------------
template <size_t S, typename T>
template <size_t D>
point<D,T> point<S,T>::redim (T fill) const
{
point<D,T> out;
auto cursor = std::copy_n (std::begin (this->data),
min (S, D),
std::begin (out.data));
std::fill (cursor, std::end (out.data), fill);
return out;
}
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
template <size_t S, typename T> template <size_t S, typename T>
template <typename U> template <typename U>