Why is the address of an array element sometimes erroneous to declare?

I have certain user-defined iterators, and from time to time I get a strange error that is easy to work with, but I don't understand why I get it:

uint8_t bytes[pitch*height];

array_iterator::col_iterator a( &bytes[0] );

array_iterator::row_iterator base_iter_begin(
  array_iterator::col_iterator( &bytes[0] ), width, pitch );

array_iterator::row_iterator base_iter_end(
  array_iterator::col_iterator( &bytes[pitch*height] ), width, pitch
  );

I have a class called array_iterator with built-in typedefs row_iterator and col_iterator. The row_iterator constructor takes col_iterator as the first argument. The first and last expression work very well. The middle expression cannot compile with the following error:

test-2d-iterators.cc:780: error: declaration of 'bytes' as array of references

Writing & (bytes [0]) (, [] , &). , "a" col_iterator, ? , col_iterator ?

.

+5
1

, :

struct row_iterator { ... };
typedef unsigned* col_iterator;
unsigned bytes[5];
row_iterator base_iter_begin(col_iterator(&bytes[0]));

:

row_iterator base_iter_begin(col_iterator& bytes[0]);

, 0 col_iterator int. , .

- ( ++):

row_iterator base_iter_begin = row_iterator(col_iterator(&bytes[0]));

:

array_iterator::row_iterator base_iter_begin = array_iterator::row_iterator(array_iterator::col_iterator( &bytes[0] ), width, pitch );

. ++ 11, , , :

array_iterator::row_iterator base_iter_begin{array_iterator::col_iterator(&bytes[0]), width, pitch};
+2

All Articles