image: add cend/cbegin

This commit is contained in:
Danny Robson 2015-09-21 12:35:44 +10:00
parent 118d1accce
commit 3af04b7982
2 changed files with 33 additions and 10 deletions

View File

@ -301,7 +301,7 @@ buffer<T>::operator[] (size_t idx)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
template <typename T> template <typename T>
inline T* T*
buffer<T>::data (void) buffer<T>::data (void)
{ {
return begin (); return begin ();
@ -310,7 +310,7 @@ buffer<T>::data (void)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <typename T> template <typename T>
inline T* T*
buffer<T>::begin (void) buffer<T>::begin (void)
{ {
return m_data.get (); return m_data.get ();
@ -319,7 +319,7 @@ buffer<T>::begin (void)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <typename T> template <typename T>
inline T* T*
buffer<T>::end (void) buffer<T>::end (void)
{ {
return begin () + h * s; return begin () + h * s;
@ -328,7 +328,25 @@ buffer<T>::end (void)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <typename T> template <typename T>
inline const T* const T*
buffer<T>::begin (void) const
{
return cbegin ();
}
//-----------------------------------------------------------------------------
template <typename T>
const T*
buffer<T>::end (void) const
{
return cend ();
}
//-----------------------------------------------------------------------------
template <typename T>
const T*
buffer<T>::data (void) const buffer<T>::data (void) const
{ {
return begin (); return begin ();
@ -337,8 +355,8 @@ buffer<T>::data (void) const
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <typename T> template <typename T>
inline const T* const T*
buffer<T>::begin (void) const buffer<T>::cbegin (void) const
{ {
return m_data.get (); return m_data.get ();
} }
@ -346,14 +364,14 @@ buffer<T>::begin (void) const
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <typename T> template <typename T>
inline const T* const T*
buffer<T>::end (void) const buffer<T>::cend (void) const
{ {
return begin () + h * s; return cbegin () + h * s;
} }
//----------------------------------------------------------------------------- ///////////////////////////////////////////////////////////////////////////////
template struct util::image::buffer<char>; template struct util::image::buffer<char>;
template struct util::image::buffer<uint8_t>; template struct util::image::buffer<uint8_t>;
template struct util::image::buffer<uint16_t>; template struct util::image::buffer<uint16_t>;
@ -362,6 +380,8 @@ template struct util::image::buffer< int32_t>;
template struct util::image::buffer<float>; template struct util::image::buffer<float>;
template struct util::image::buffer<double>; template struct util::image::buffer<double>;
template util::image::buffer<char> util::image::buffer<char>::alloc (void) const;
template util::image::buffer<uint8_t> util::image::buffer<uint8_t>::alloc (void) const; template util::image::buffer<uint8_t> util::image::buffer<uint8_t>::alloc (void) const;
template util::image::buffer<uint8_t> util::image::buffer<uint8_t>::clone (void) const; template util::image::buffer<uint8_t> util::image::buffer<uint8_t>::clone (void) const;
template util::image::buffer<uint8_t> util::image::buffer<float>::clone (void) const; template util::image::buffer<uint8_t> util::image::buffer<float>::clone (void) const;

View File

@ -78,6 +78,9 @@ namespace util { namespace image {
const T* end (void) const; const T* end (void) const;
const T* data (void) const; const T* data (void) const;
const T* cbegin (void) const;
const T* cend (void) const;
private: private:
std::unique_ptr<T[]> m_data; std::unique_ptr<T[]> m_data;
}; };