image: index operator should return references
this allows the caller to use the return value's address
This commit is contained in:
parent
040e935b6d
commit
b084cb2e4c
@ -255,7 +255,7 @@ util::image::buffer<T>::downsample (float factor) const
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T
|
const T&
|
||||||
buffer<T>::operator[] (point<2,size_t> p) const
|
buffer<T>::operator[] (point<2,size_t> p) const
|
||||||
{
|
{
|
||||||
CHECK_LT (p.x, w);
|
CHECK_LT (p.x, w);
|
||||||
@ -279,7 +279,7 @@ buffer<T>::operator[] (point<2,size_t> p)
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T
|
const T&
|
||||||
buffer<T>::operator[] (size_t idx) const
|
buffer<T>::operator[] (size_t idx) const
|
||||||
{
|
{
|
||||||
CHECK_LT (idx, h * s);
|
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<uint8_t>;
|
||||||
template struct util::image::buffer<uint16_t>;
|
template struct util::image::buffer<uint16_t>;
|
||||||
template struct util::image::buffer<uint32_t>;
|
template struct util::image::buffer<uint32_t>;
|
||||||
|
@ -63,10 +63,10 @@ namespace util { namespace image {
|
|||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
constexpr size_t offset (point<2,size_t>) const;
|
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[] (point<2,size_t>);
|
||||||
|
|
||||||
T operator[] (size_t) const;
|
const T& operator[] (size_t) const;
|
||||||
T& operator[] (size_t);
|
T& operator[] (size_t);
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user