bimap
#include <iostream>
#include <boost/assign.hpp>
#include <boost/typeof/typeof.hpp>
#include <boost/bimap.hpp>
#include <boost/bimap/list_of.hpp>
#include <boost/bimap/unordered_multiset_of.hpp>
#include <boost/bimap/unordered_set_of.hpp>
#include <boost/bimap/vector_of.hpp>
#include <boost/bimap/set_of.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/bimap/unconstrained_set_of.hpp>
#include <algorithm>
using namespace std;
using namespace boost;
using namespace boost::bimaps;
template <typename T>
void print_map(T &m)
{
for (BOOST_AUTO(pos, m.begin()); pos != m.end(); ++pos)
{
cout << pos->left << "------" << pos->right << endl;
}
}
template <typename T>
void print_map1(T &m)
{
for (BOOST_AUTO(pos, m.begin()); pos != m.end(); ++pos)
{
cout << pos->first << "------" << pos->second << endl;
}
}
int main()
{
bimap<unordered_multiset_of<int>, unordered_multiset_of<string>>bm;
bm.left.insert(make_pair(1,"111"));
bm.left.insert(make_pair(2,"222"));
bm.left.insert(make_pair(3,"333"));
bm.right.insert(make_pair("4444",4));
bm.right.insert(make_pair("5555",5));
bm.right.insert(make_pair("4444",6));
bm.right.insert(make_pair("7777", 3));
print_map(bm);
bimap<set_of<int>, vector_of<string>>bm1;
bm1.left.insert(make_pair(1,"1111"));
bm1.left[2] = "2222";
print_map(bm1);
using namespace boost::bimaps;
bimap<tagged<int,struct id>,tagged<string,struct name>> bm2;
bm2.by<id>().insert(make_pair(1,"lijiajia"));
bm2.by<id>().insert(make_pair(2,"caoyanyan"));
bm2.by<name>().insert(make_pair("weiyimeng",3));
bm2.by<name>().insert(make_pair("hahahha",4));
print_map1(bm2.by<name>());
return 0;
}