I think there is some minor terminology abuse going on here. STL algorithms operate on ranges (more precisely collections). Ranges have a beginning and an end, which are specified by iterators. The iterator type itself could be a template parameter. This is the way the STL algorithms were designed and it decouples the algorithm from the type of container.
There are two benefits from this change that immediately come to mind:
1. The container could be swapped out inside main and the function would still remain compatible.
2. The function could be called to operate on any subset of the containers contents.
Possible drawbacks, as pointed out by kempofighter, do exist. The function in question, though, doesn't appear to be very dependent on the container type.
Updating the function above to accept two iterators rather than a container reference would be beneficial to say the least.
Then again, if you were just dumping the values to cout, there is always:
|
copy( tmparray, tmparray + 10, ostream_iterator<char>( cout ) );
| |
Null-terminating the array and just using cout is an idea, too...