• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 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
17 
18 #include <boost/config.hpp>
19 
20 // std
21 #include <set>
22 #include <map>
23 #include <cstddef>
24 #include <cassert>
25 #include <algorithm>
26 
27 #include <boost/core/lightweight_test.hpp>
28 
29 // Boost.Bimap
30 
31 #include <boost/bimap/set_of.hpp>
32 #include <boost/bimap/property_map/set_support.hpp>
33 
34 #include <boost/bimap/unordered_set_of.hpp>
35 #include <boost/bimap/property_map/unordered_set_support.hpp>
36 
37 #include <boost/bimap/bimap.hpp>
38 
39 
40 template <class Map>
test_readable_property_map(Map m,typename boost::property_traits<Map>::key_type const & key,typename boost::property_traits<Map>::value_type const & value)41 void test_readable_property_map(
42     Map m,
43     typename boost::property_traits<Map>::  key_type const & key,
44     typename boost::property_traits<Map>::value_type const & value
45 )
46 {
47     // TODO Add STATIC_ASSERT(
48     //              boost::property_traits<Map>::category is readable )
49 
50     BOOST_TEST( get(m,key) == value );
51     //BOOST_TEST( m[key]     == value );
52 }
53 
54 
test_bimap_property_map()55 void test_bimap_property_map()
56 {
57     using namespace boost::bimaps;
58 
59     typedef bimap< set_of<int>, unordered_set_of<double> > bm;
60 
61     bm b;
62     b.insert( bm::value_type(1,0.1) );
63     b.insert( bm::value_type(2,0.2) );
64     b.insert( bm::value_type(3,0.3) );
65 
66     test_readable_property_map(b.left ,  1,0.1);
67     test_readable_property_map(b.right,0.1,  1);
68 }
69 
main()70 int main()
71 {
72     test_bimap_property_map();
73     return boost::report_errors();
74 }
75 
76