1.靜態數組array,boost對靜態數組進行了封裝,使用和普通數組一樣的初始化式進行初始化。
#include <iostream>
#include <boost/array.hpp>
using namespace std;
using namespace boost;
int main()
{
array<int,10> ar;
ar.back() = 10;
array<string,3> ar1 = {"tiger","dog","cat"};
return 0;
}
2.dynamic_bitset可以自由擴充二進制位的位數,可以自由進行位操作,還有一堆方便操作判斷的函數。
#include <iostream>
#include <boost/dynamic_bitset.hpp>
using namespace std;
using namespace boost;
int main()
{
dynamic_bitset<> db1;
dynamic_bitset<> db2(10);
cout << db2 <<endl;
db2.resize(6,true);
cout << db2 <<endl;
dynamic_bitset<> db3(string("100010"));
cout << db3<<endl;
cout << (db2 ^ db3) <<endl;
cout << (db2 & db3) <<endl;
if (db2.none())
{
cout << "have no 1"<<endl;
}
return 0;
}
3.unordered和hash_set,hash_map一樣底層使用哈希表代替二叉樹,實現關聯容器。
4.bimap雙向map
#include <iostream>
#include <string>
#include <boost/bimap.hpp>
using namespace std;
using namespace boost;
int main()
{
bimap<int,string> bm;
bm.left.insert(make_pair(1,"111"));
bm.left.insert(make_pair(2,"222"));
bm.right.insert(make_pair("string",3));
bm.right.insert(make_pair("bimap",4));
for (bimap<int,string>::right_iterator it = bm.right.begin();it != bm.right.end();++it)
{
cout << it->second <<endl;
}
return 0;
}
5.any可以被初始化或者賦值任意類型的數據
#include <iostream>
#include <string>
#include <boost/any.hpp>
using namespace std;
using namespace boost;
int main()
{
any a(100);
a =string("char *");
//a = vector<vector<>int >();
return 0;
}
