3 // Copyright (c) 2006-2007 Matias Capeletto
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // VC++ 8.0 warns on usage of certain Standard Library and API functions that
10 // can be cause buffer overruns or other possible security issues if misused.
11 // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx
12 // But the wording of the warning is misleading and unsettling, there are no
13 // portable alternative functions, and VC++ 8.0's own libraries use the
14 // functions in question. So turn off the warnings.
15 #define _CRT_SECURE_NO_DEPRECATE
16 #define _SCL_SECURE_NO_DEPRECATE
18 // Boost.Bimap Example
19 //-----------------------------------------------------------------------------
20 // This is the translator example from the tutorial.
21 // In this example the set type of relation is changed to allow the iteration
24 #include <boost/config.hpp>
30 #include <boost/bimap/bimap.hpp>
31 #include <boost/bimap/list_of.hpp>
32 #include <boost/bimap/unordered_set_of.hpp>
39 using namespace boost::bimaps;
43 unordered_set_of< tagged< std::string, spanish > >,
44 unordered_set_of< tagged< std::string, english > >,
51 // We have to use `push_back` because the collection of relations is
52 // a `list_of_relation`
54 trans.push_back( translator::value_type("hola" ,"hello" ) );
55 trans.push_back( translator::value_type("adios" ,"goodbye" ) );
56 trans.push_back( translator::value_type("rosa" ,"rose" ) );
57 trans.push_back( translator::value_type("mesa" ,"table" ) );
59 std::cout << "enter a word" << std::endl;
61 std::getline(std::cin,word);
63 // Search the queried word on the from index (Spanish)
65 translator::map_by<spanish>::const_iterator is
66 = trans.by<spanish>().find(word);
68 if( is != trans.by<spanish>().end() )
70 std::cout << word << " is said "
72 << " in English" << std::endl;
76 // Word not found in Spanish, try our luck in English
78 translator::map_by<english>::const_iterator ie
79 = trans.by<english>().find(word);
81 if( ie != trans.by<english>().end() )
83 std::cout << word << " is said "
85 << " in Spanish" << std::endl;
89 // Word not found, show the possible translations
91 std::cout << "No such word in the dictionary" << std::endl;
92 std::cout << "These are the possible translations" << std::endl;
94 for( translator::const_iterator
100 std::cout << i->get<spanish>()