Ie, is there any difference between
subrange(V, 0, 3);
and
project(V, range(0,3));
?
I ask because I'm digging into some code that seems to use both forms (with no apparent rhyme/reason for one vs. the other), but I can't see any difference between the two... just wanted to check to make sure I'm not missing something.
Looked into it, and I've confirmed there is no difference - subrange is simply an easy wrapper for a common-case of project, and in these cases:
subrange(V, 0, 3);
project(V, range(0,3));
...they end up identical. So using either should be fine, as long as you're consistent!
For the more curious... subrange does:
template<class V>
vector_range<V> subrange (V &data, typename V::size_type start, typename V::size_type stop) {
typedef basic_range<typename V::size_type, typename V::difference_type> range_type;
return vector_range<V> (data, range_type (start, stop));
}
while project does:
template<class V>
vector_range<V> project (V &data, typename vector_range<V>::range_type const &r) {
return vector_range<V> (data, r);
}
..and since vector_range::range_type is defined to be
typedef basic_range<size_type, difference_type> range_type;
...ie, exactly what is used in subrange, the two forms are identical.