簡體   English   中英

C ++中范圍的狀態是什么?

[英]What is the status of ranges in C++?

有時我厭倦了所有這些my_vector.begin(), my_vector.end()噪音。 去年在boostcon上,Andrei Alexandrescu的主題演講名為Iterators Must Go視頻

將范圍引入C ++是否有任何進展,所以我最終可以說std::sort(my_vector)

C ++中的范圍仍然沒有足夠的經驗。
作為當前的實驗實現,有Boost.Range 2.0和Oven Range Library。

據我所知,在這方面沒有取得任何進展。

#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, " " ) );
}

當然,替換成員函數調用以startOfendOf (您的版本)的調用beginend ,至少直到C ++ 0x ...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM