]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/bimap/example/projection.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / bimap / example / projection.cpp
1 // Boost.Bimap
2 //
3 // Copyright (c) 2006-2007 Matias Capeletto
4 //
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)
8
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 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
17
18 // Boost.Bimap Example
19 //-----------------------------------------------------------------------------
20
21 #include <boost/config.hpp>
22
23 #include <string>
24 #include <iostream>
25
26 #include <boost/bimap/bimap.hpp>
27 #include <boost/bimap/multiset_of.hpp>
28 using namespace boost::bimaps;
29
30 void years_example()
31 {
32 //[ code_projection_years
33
34 typedef bimap<std::string,multiset_of<int,std::greater<int> > > bm_type;
35
36 bm_type bm;
37 bm.insert( bm_type::value_type("John" ,34) );
38 bm.insert( bm_type::value_type("Peter",24) );
39 bm.insert( bm_type::value_type("Mary" ,12) );
40
41 // Find the name of the next younger person after Peter
42
43 bm_type::left_const_iterator name_iter = bm.left.find("Peter");
44
45 bm_type::right_const_iterator years_iter = bm.project_right(name_iter);
46
47 ++years_iter;
48
49 std::cout << "The next younger person after Peter is " << years_iter->second;
50 //]
51 }
52
53 int main()
54 {
55 years_example();
56
57 return 0;
58 }
59
60