point: add redim with fill
This commit is contained in:
parent
64c11bdcb0
commit
917ab8fc8e
@ -57,6 +57,7 @@ namespace util {
|
|||||||
bool operator== (const point<S,T>&) const;
|
bool operator== (const point<S,T>&) const;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
static const point<S,T> ORIGIN;
|
static const point<S,T> ORIGIN;
|
||||||
|
|
||||||
|
24
point.ipp
24
point.ipp
@ -68,7 +68,29 @@ namespace util {
|
|||||||
template<size_t D>
|
template<size_t D>
|
||||||
point<D,T> point<S,T>::redim (void) const {
|
point<D,T> point<S,T>::redim (void) const {
|
||||||
point<D,T> out;
|
point<D,T> out;
|
||||||
std::copy (std::begin (this->data), std::begin (this->data) + D, std::begin (out.data));
|
std::copy_n (std::begin (this->data),
|
||||||
|
min (S, D),
|
||||||
|
std::begin (out.data));
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
template<size_t S, typename T>
|
||||||
|
template<size_t D>
|
||||||
|
point<D,T> point<S,T>::redim (const point<D,T> &fill) const {
|
||||||
|
point<D,T> out;
|
||||||
|
|
||||||
|
static constexpr auto L1 = min (S, D);
|
||||||
|
static constexpr auto L2 = D - L1;
|
||||||
|
|
||||||
|
std::copy_n (std::begin (this->data),
|
||||||
|
L1,
|
||||||
|
std::begin (out.data));
|
||||||
|
|
||||||
|
std::copy_n (fill.data + L1,
|
||||||
|
L2,
|
||||||
|
out.data + L1);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user