This was, by the way, one of the reasons I thought
std::vector interfaces would be easier and more portable.
What Michael's suggesting is probably the path of least
resistance and shouldn't be inefficient (other than to
compile).
A more idiomatic approach within C++ would be to define the
interfaces in terms of iterators. A more generic way to do
it with references to container arguments would be to template
out the container type and just use accessors (for example, []
works for arrays, standard vectors, C++11 arrays, Eigen vectors, and
many of the Boost sequence containers). The cost is that the code's a
bit more complex, which is why we've (or at least I've) tended not
to do it that way. But I think we're all getting better at C++,
so maybe this shouldn't be such a hurdle any more.
- Bob