boost簡化

//
int arr[5]={1,2,3,4,5};
for(int i=1;i<=5;i++){
	cout<<arr[i]<<endl;
}
//C++11簡潔方法
for(int &e:arr){
	cout<<e<<endl;
}
//boost
BOOST_FOREACH(auto &e,arr){//逗號分隔
	cout<<e<<endl;
}
//
vector<int> v;
v.push(1);
v.push(2);
v.push(3);
v.push(4);
v.push(5);
//常見vector循環
for(vector<int>::iterator it = v.begin;it!=v.end();++it)
//boost在vector的循環非常簡單,還可以倒敘輸出
BOOST_FOREACH(auto & e,v)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章