Reputation: 263098
Sometimes I get tired of all this my_vector.begin(), my_vector.end()
noise. Last year at boostcon, Andrei Alexandrescu's keynote speech was titled Iterators Must Go (video)
Is there any progress on introducing ranges into C++, so I can finally say std::sort(my_vector)
?
Upvotes: 16
Views: 1089
Reputation: 3012
Range in C++ still has an insufficient experience.
As current experimental implementation, there are Boost.Range 2.0 and Oven Range Library.
Upvotes: 6
Reputation: 145224
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
template< class Container >
void sort( Container& c ) { sort( c.begin(), c.end() ); }
int main()
{
using namespace std;
int const data[] = {3, 1, 4, 1, 5, 9, 2, 6, 5, 4};
vector<int> v( data, data + sizeof( data )/sizeof( *data ) );
sort( v );
copy( v.begin(), v.end(), ostream_iterator<int>( cout, " " ) );
}
Of course, replace member function calls begin
and end
with calls of startOf
and endOf
(your versions), at least until C++0x...
Upvotes: 2
Reputation: 40849
As far as I know, no progress has been made toward that end.
Upvotes: 2