STL arrray,及部分stl容器通用函数(begin(),rend())
arrray(.fill() .swap() .clear() move auto initialtion list初始化列表
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
using namespace std;
int main()
{
vector< int> a{56,45,65};
vector <int> c=a;//c(a)
vector <int> d=move(a);
a.clear();
sort(d.begin(),d.end());
cout<<d.front()<<endl;
cout<<d.empty()<<endl;
cout<<d.back()<<endl;
for(auto pos=d.cbegin();pos<d.cend();pos++)
cout<<*pos<<" ";
cout<<endl;
for(auto pos=d.crbegin();pos<d.crend();pos++)
{
cout<<*pos<<" ";
// *pos=45 false syntax ;
}
cout<<endl;
for(auto pos=d.rbegin();pos<d.rend();pos++)
{
*pos=10;
cout<<*pos<<" ";
}
cout<<endl;
cout<<d.max_size();//element accout;
string two[2]={"dsfa","fsd"};
array<string,2> str{"asdfa","fasdafd"};
str.fill("0");//assign value to each element
swap(d,c);
d.swap(c);
vector<int > ::const_iterator p1;
for(p1=d.begin();p1<d.end();p1++)
{
}
return 0;
}