#include <boost/bimap.hpp>
#include <boost/typeof/typeof.hpp>
#include <iostream>
#include <string>
using namespace std;
using namespace boost;
int main(int argc, _TCHAR* argv[])
{
bimap<int,string>bm;
bm.left.insert(std::make_pair(1,"sty1")); //向左视图添加数据
bm.left.insert(std::make_pair(2,"sty2"));
bm.right.insert(std::make_pair("string1",10)); //向右视图添加数据
bm.right.insert(std::make_pair("string2",11));
bm.right.insert(std::make_pair("string3",12));
for (BOOST_AUTO(pos, bm.left.begin()); pos != bm.left.end(); ++pos) //使用左视图遍历输出
{
cout<<"left: "<<pos->first<<"\t="<<pos->second<<endl;
}
return EXIT_SUCCESS;
#include <boost/typeof/typeof.hpp>
#include <iostream>
#include <string>
using namespace std;
using namespace boost;
int main(int argc, _TCHAR* argv[])
{
bimap<int,string>bm;
bm.left.insert(std::make_pair(1,"sty1")); //向左视图添加数据
bm.left.insert(std::make_pair(2,"sty2"));
bm.right.insert(std::make_pair("string1",10)); //向右视图添加数据
bm.right.insert(std::make_pair("string2",11));
bm.right.insert(std::make_pair("string3",12));
for (BOOST_AUTO(pos, bm.left.begin()); pos != bm.left.end(); ++pos) //使用左视图遍历输出
{
cout<<"left: "<<pos->first<<"\t="<<pos->second<<endl;
}
return EXIT_SUCCESS;
}
output:
left1 =sty1
left2 =sty2
left10 =string1
left11 =string2
left12 =string3