]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/bimap/example/tagged_simple_bimap.cpp
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 //-----------------------------------------------------------------------------
21 #include <boost/config.hpp>
23 //[ code_tagged_simple_bimap
27 #include <boost/bimap.hpp>
34 using namespace boost::bimaps
;
40 tagged
< std::string
, country
>,
45 typedef results_bimap::value_type position
;
47 results_bimap results
;
48 results
.insert( position("Argentina" ,1) );
49 results
.insert( position("Spain" ,2) );
50 results
.insert( position("Germany" ,3) );
51 results
.insert( position("France" ,4) );
53 std::cout
<< "Countries names ordered by their final position:"
56 /*<< `results.by<place>()` is equivalent to `results.right` >>*/
57 for( results_bimap::map_by
<place
>::const_iterator
58 i
= results
.by
<place
>().begin(),
59 iend
= results
.by
<place
>().end() ;
62 /*<< `get<Tag>` works for each view of the bimap >>*/
63 std::cout
<< i
->get
<place
>() << ") "
64 << i
->get
<country
>() << std::endl
;
67 std::cout
<< std::endl
68 << "Countries names ordered alfabetically along with"
69 "their final position:"
72 /*<< `results.by<country>()` is equivalent to `results.left` >>*/
73 for( results_bimap::map_by
<country
>::const_iterator
74 i
= results
.by
<country
>().begin(),
75 iend
= results
.by
<country
>().end() ;
78 std::cout
<< i
->get
<country
>() << " ends "
79 << i
->get
<place
>() << "ยบ"