From 3af04b79823124ba89ec48d78d865b7d2b0a8cbc Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 21 Sep 2015 12:35:44 +1000 Subject: [PATCH] image: add cend/cbegin --- image.cpp | 40 ++++++++++++++++++++++++++++++---------- image.hpp | 3 +++ 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/image.cpp b/image.cpp index 2cde6f83..e482fb1b 100644 --- a/image.cpp +++ b/image.cpp @@ -301,7 +301,7 @@ buffer::operator[] (size_t idx) /////////////////////////////////////////////////////////////////////////////// template -inline T* +T* buffer::data (void) { return begin (); @@ -310,7 +310,7 @@ buffer::data (void) //----------------------------------------------------------------------------- template -inline T* +T* buffer::begin (void) { return m_data.get (); @@ -319,7 +319,7 @@ buffer::begin (void) //----------------------------------------------------------------------------- template -inline T* +T* buffer::end (void) { return begin () + h * s; @@ -328,7 +328,25 @@ buffer::end (void) //----------------------------------------------------------------------------- template -inline const T* +const T* +buffer::begin (void) const +{ + return cbegin (); +} + + +//----------------------------------------------------------------------------- +template +const T* +buffer::end (void) const +{ + return cend (); +} + + +//----------------------------------------------------------------------------- +template +const T* buffer::data (void) const { return begin (); @@ -337,8 +355,8 @@ buffer::data (void) const //----------------------------------------------------------------------------- template -inline const T* -buffer::begin (void) const +const T* +buffer::cbegin (void) const { return m_data.get (); } @@ -346,14 +364,14 @@ buffer::begin (void) const //----------------------------------------------------------------------------- template -inline const T* -buffer::end (void) const +const T* +buffer::cend (void) const { - return begin () + h * s; + return cbegin () + h * s; } -//----------------------------------------------------------------------------- +/////////////////////////////////////////////////////////////////////////////// template struct util::image::buffer; template struct util::image::buffer; template struct util::image::buffer; @@ -362,6 +380,8 @@ template struct util::image::buffer< int32_t>; template struct util::image::buffer; template struct util::image::buffer; +template util::image::buffer util::image::buffer::alloc (void) const; + template util::image::buffer util::image::buffer::alloc (void) const; template util::image::buffer util::image::buffer::clone (void) const; template util::image::buffer util::image::buffer::clone (void) const; diff --git a/image.hpp b/image.hpp index 3b59e5ce..fd48049c 100644 --- a/image.hpp +++ b/image.hpp @@ -78,6 +78,9 @@ namespace util { namespace image { const T* end (void) const; const T* data (void) const; + const T* cbegin (void) const; + const T* cend (void) const; + private: std::unique_ptr m_data; };