image: index operator should return references

this allows the caller to use the return value's address
This commit is contained in:
Danny Robson 2015-09-15 21:08:00 +10:00
parent 040e935b6d
commit b084cb2e4c
2 changed files with 5 additions and 4 deletions

View File

@ -255,7 +255,7 @@ util::image::buffer<T>::downsample (float factor) const
///////////////////////////////////////////////////////////////////////////////
template <typename T>
T
const T&
buffer<T>::operator[] (point<2,size_t> p) const
{
CHECK_LT (p.x, w);
@ -279,7 +279,7 @@ buffer<T>::operator[] (point<2,size_t> p)
//-----------------------------------------------------------------------------
template <typename T>
T
const T&
buffer<T>::operator[] (size_t idx) const
{
CHECK_LT (idx, h * s);
@ -354,6 +354,7 @@ buffer<T>::end (void) const
//-----------------------------------------------------------------------------
template struct util::image::buffer<char>;
template struct util::image::buffer<uint8_t>;
template struct util::image::buffer<uint16_t>;
template struct util::image::buffer<uint32_t>;

View File

@ -63,10 +63,10 @@ namespace util { namespace image {
//---------------------------------------------------------------------
constexpr size_t offset (point<2,size_t>) const;
T operator[] (point<2,size_t>) const;
const T& operator[] (point<2,size_t>) const;
T& operator[] (point<2,size_t>);
T operator[] (size_t) const;
const T& operator[] (size_t) const;
T& operator[] (size_t);
//---------------------------------------------------------------------