// Boost.Bimap // // Copyright (c) 2006-2007 Matias Capeletto #define _CRT_SECURE_NO_DEPRECATE #define _SCL_SECURE_NO_DEPRECATE // Boost.Bimap Example //----------------------------------------------------------------------------- #include #include #include struct country {}; struct place {}; using namespace boost::bimaps; template class X { typedef bimap < tagged< std::string, country >, tagged< T , place > > results_bimap; typedef typename results_bimap::value_type position; public: X() { results_bimap results; results.insert( position("Argentina" ,1) ); results.insert( position("Spain" ,2) ); results.insert( position("Germany" ,3) ); results.insert( position("France" ,4) ); std::cout << "Countries names ordered by their final position:" << std::endl; /*<< `results.by()` is equivalent to `results.right` >>*/ for( typename results_bimap::map_by::const_iterator i = results.by().begin(), iend = results.by().end() ; i != iend; ++i ) { /*<< `get` works for each view of the bimap >>*/ std::cout << i->get() << ") " << i->get() << std::endl; } std::cout << std::endl << "Countries names ordered alfabetically along with" "their final position:" << std::endl; /*<< `results.by()` is equivalent to `results.left` >>*/ for( typename results_bimap::map_by::const_iterator i = results.by().begin(), iend = results.by().end() ; i != iend; ++i ) { std::cout << i->get() << " ends " << i->get() << "ยบ" << std::endl; } }; }; int main() { X x; return 0; }