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>
26 #include <boost/bimap/bimap.hpp>
27 #include <boost/bimap/support/lambda.hpp>
29 using namespace boost::bimaps
;
31 void using_upper_and_lower_bound()
33 //[ code_tutorial_range_standard_way
35 typedef bimap
<int,std::string
> bm_type
;
40 bm_type::left_iterator iter_first
= bm
.left
.lower_bound(20);
41 bm_type::left_iterator iter_second
= bm
.left
.upper_bound(50);
43 // range [iter_first,iter_second) contains the elements in [20,50]
48 //[ code_tutorial_range_standard_way_subtle_changes
50 bm_type::left_iterator iter_first
= bm
.left
.upper_bound(20);
51 bm_type::left_iterator iter_second
= bm
.left
.lower_bound(50);
53 // range [iter_first,iter_second) contains the elements in (20,50)
60 //[ code_tutorial_range
62 typedef bimap
<int,std::string
> bm_type
;
67 /*<< `range_type` is a handy typedef equal to `std::pair<iterator,iterator>`.
68 `const_range_type` is provided too, and it is equal to
69 `std::pair<const_iterator,const_iterator>` >>*/
70 bm_type::left_range_type r
;
72 /*<< _key is a Boost.Lambda placeholder. To use it you have to include
73 `<boost/bimap/support/lambda.hpp>` >>*/
74 r
= bm
.left
.range( 20 <= _key
, _key
<= 50 ); // [20,50]
76 r
= bm
.left
.range( 20 < _key
, _key
< 50 ); // (20,50)
78 r
= bm
.left
.range( 20 <= _key
, _key
< 50 ); // [20,50)
81 //[ code_tutorial_range_unbounded
83 r
= bm
.left
.range( 20 <= _key
, unbounded
); // [20,inf)
85 r
= bm
.left
.range( unbounded
, _key
< 50 ); // (-inf,50)
87 /*<< This is equivalent to std::make_pair(s.begin(),s.end()) >>*/
88 r
= bm
.left
.range( unbounded
, unbounded
); // (-inf,inf)
94 using_upper_and_lower_bound();