]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/bimap/example/bimap_and_boost/typeof.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 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>
25 #include <boost/bimap/bimap.hpp>
27 #include <boost/typeof/typeof.hpp>
29 using namespace boost::bimaps
;
36 //[ code_bimap_and_boost_typeof_first
38 typedef bimap
< tagged
<std::string
,name
>, tagged
<int,number
> > bm_type
;
40 bm
.insert( bm_type::value_type("one" ,1) );
41 bm
.insert( bm_type::value_type("two" ,2) );
44 //[ code_bimap_and_boost_typeof_using_auto
46 for( BOOST_AUTO(iter
, bm
.by
<name
>().begin()); iter
!=bm
.by
<name
>().end(); ++iter
)
48 std::cout
<< iter
->first
<< " --> " << iter
->second
<< std::endl
;
51 BOOST_AUTO( iter
, bm
.by
<number
>().find(2) );
52 std::cout
<< "2: " << iter
->get
<name
>();
58 typedef bimap
< tagged
<std::string
,name
>, tagged
<int,number
> > bm_type
;
60 bm
.insert( bm_type::value_type("one" ,1) );
61 bm
.insert( bm_type::value_type("two" ,2) );
63 //[ code_bimap_and_boost_typeof_not_using_auto
65 for( bm_type::map_by
<name
>::iterator iter
= bm
.by
<name
>().begin();
66 iter
!=bm
.by
<name
>().end(); ++iter
)
68 std::cout
<< iter
->first
<< " --> " << iter
->second
<< std::endl
;
71 bm_type::map_by
<number
>::iterator iter
= bm
.by
<number
>().find(2);
72 std::cout
<< "2: " << iter
->get
<name
>();