From 049aaf84c98e13c154239d5e1d64928496fcee88 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 19 Feb 2015 13:19:02 +1100 Subject: [PATCH] point: add redim with constant --- point.hpp | 1 + point.ipp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/point.hpp b/point.hpp index 1890dff7..34d73680 100644 --- a/point.hpp +++ b/point.hpp @@ -59,6 +59,7 @@ namespace util { template point redim (void) const; template point redim (const util::point &fill) const; + template point redim (T fill) const; static const point ORIGIN; diff --git a/point.ipp b/point.ipp index 22e3b295..bef9db60 100644 --- a/point.ipp +++ b/point.ipp @@ -95,6 +95,22 @@ namespace util { } + //------------------------------------------------------------------------- + template + template + point point::redim (T fill) const + { + point 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 template