
2 Dec
2013
2 Dec
'13
7:56 a.m.
Mostafa
Working with built-in array objects I find myself repeatedly needing to get the address of the first non-array element. This is so I can do generic array comparisons and copies without resorting to multiple loops. For example:
template
bool generic_array_equal(T (&lhs)[N], T const (&rhs)[N]) { return std::equal( address_of_first_nonarray_elem(lhs), address_of_first_nonarray_elem(lhs) + total_extent ::size, address_of_first_nonarray_elem(rhs)); } Any interest in adding such a function to the util library?
Why the "non"? Shouldn't the name be "address_of_first_array_elem"? How is this different from std::begin(lhs)? Joaquín M López Muñoz Telefónica Digital