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 <sstream>
22#include <algorithm>
23#include <set>
24
25// Boost
26#include <boost/assign/list_of.hpp>
27#include <boost/assign/list_inserter.hpp>
28
29// Boost.Bimap
30#include <boost/bimap/list_of.hpp>
31#include <boost/bimap/unordered_multiset_of.hpp>
32#include <boost/bimap/vector_of.hpp>
33#include <boost/bimap/bimap.hpp>
34
35namespace ba = boost::assign;
36
37
38void test_bimap_assign()
39{
40 using namespace boost::bimaps;
41
42 // test
43 {
44 typedef bimap< list_of<int>, double > bm_type;
45 bm_type bm = ba::list_of< bm_type::relation >(u: 1,us: 0.1)(2,0.2)(3,0.3);
46 ba::push_back( c&: bm )(4,0.4)(5,0.5);
47 ba::insert( c&: bm.right )(0.5,5)(0.6,6);
48 ba::push_back( c&: bm.left )(6,0.6)(7,0.7);
49 }
50
51 // test
52 {
53 typedef bimap< unordered_multiset_of<int>, vector_of<double>,
54 list_of_relation > bm_type;
55 bm_type bm = ba::list_of< bm_type::relation >(u: 1,us: 0.1)(2,0.2)(3,0.3);
56 ba::push_front( c&: bm )(4,0.4)(5,0.5);
57 ba::push_back( c&: bm.right )(0.6,6)(0.7,7);
58 ba::insert( c&: bm.left )(8,0.8)(9,0.9);
59 }
60
61 // test
62 {
63 typedef bimap< int, vector_of<double>, right_based > bm_type;
64 bm_type bm = ba::list_of< bm_type::relation >(u: 1,us: 0.1)(2,0.2)(3,0.3);
65 ba::push_back( c&: bm )(4,0.4)(5,0.5);
66 ba::push_back( c&: bm.right )(0.6,6)(0.7,7);
67 ba::insert( c&: bm.left )(8,0.8)(9,0.9);
68 }
69
70 // test
71 {
72 typedef bimap< int, vector_of<double>, set_of_relation<> > bm_type;
73 bm_type bm = ba::list_of< bm_type::relation >(u: 1,us: 0.1)(2,0.2)(3,0.3);
74 ba::insert( c&: bm )(4,0.4)(5,0.5);
75 ba::push_back( c&: bm.right )(0.6,6)(0.7,7);
76 ba::insert( c&: bm.left )(8,0.8)(9,0.9);
77 }
78}
79
80
81int main()
82{
83 test_bimap_assign();
84 return 0;
85}
86
87

source code of boost/libs/bimap/test/test_bimap_assign.cpp