With C arrays, it's pretty easy to write code that accepts arrays of any size:
void func( T* itBegin, T* itEnd );
void main() {
T arr1[1];
func( std::begin(arr1), std::end(arr1) );
T arr2[2];
func( std::begin(arr2), std::end(arr2) );
}
How can I do this with std :: arrays?
void func( ??? itBegin, ??? itEnd );
void main() {
std::array<T,1> arr1;
func( std::begin(arr1), std::end(arr1) );
std::array<T,2> arr2;
func( std::begin(arr2), std::end(arr2) );
}
The problem is that in MSVC 2010 std::array<T,N>::iteratoris different for different N. Is this a bug in MSVC 2010? If not, what is the reason for this design? Yes, I could get pointers from std :: array and pass them instead of iterators, but isn't that too ugly?
BTW are the boost::array<T,N>::iteratorsame for everyone N.
source
share