test_bimap_assign.cpp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. // VC++ 8.0 warns on usage of certain Standard Library and API functions that
  9. // can be cause buffer overruns or other possible security issues if misused.
  10. // See https://web.archive.org/web/20071014014301/http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx
  11. // But the wording of the warning is misleading and unsettling, there are no
  12. // portable alternative functions, and VC++ 8.0's own libraries use the
  13. // functions in question. So turn off the warnings.
  14. #define _CRT_SECURE_NO_DEPRECATE
  15. #define _SCL_SECURE_NO_DEPRECATE
  16. #include <boost/config.hpp>
  17. // Boost.Test
  18. #include <boost/test/minimal.hpp>
  19. // std
  20. #include <sstream>
  21. #include <algorithm>
  22. #include <set>
  23. // Boost
  24. #include <boost/assign/list_of.hpp>
  25. #include <boost/assign/list_inserter.hpp>
  26. // Boost.Bimap
  27. #include <boost/bimap/list_of.hpp>
  28. #include <boost/bimap/unordered_multiset_of.hpp>
  29. #include <boost/bimap/vector_of.hpp>
  30. #include <boost/bimap/bimap.hpp>
  31. namespace ba = boost::assign;
  32. void test_bimap_assign()
  33. {
  34. using namespace boost::bimaps;
  35. // test
  36. {
  37. typedef bimap< list_of<int>, double > bm_type;
  38. bm_type bm = ba::list_of< bm_type::relation >(1,0.1)(2,0.2)(3,0.3);
  39. ba::push_back( bm )(4,0.4)(5,0.5);
  40. ba::insert( bm.right )(0.5,5)(0.6,6);
  41. ba::push_back( bm.left )(6,0.6)(7,0.7);
  42. }
  43. // test
  44. {
  45. typedef bimap< unordered_multiset_of<int>, vector_of<double>,
  46. list_of_relation > bm_type;
  47. bm_type bm = ba::list_of< bm_type::relation >(1,0.1)(2,0.2)(3,0.3);
  48. ba::push_front( bm )(4,0.4)(5,0.5);
  49. ba::push_back( bm.right )(0.6,6)(0.7,7);
  50. ba::insert( bm.left )(8,0.8)(9,0.9);
  51. }
  52. // test
  53. {
  54. typedef bimap< int, vector_of<double>, right_based > bm_type;
  55. bm_type bm = ba::list_of< bm_type::relation >(1,0.1)(2,0.2)(3,0.3);
  56. ba::push_back( bm )(4,0.4)(5,0.5);
  57. ba::push_back( bm.right )(0.6,6)(0.7,7);
  58. ba::insert( bm.left )(8,0.8)(9,0.9);
  59. }
  60. // test
  61. {
  62. typedef bimap< int, vector_of<double>, set_of_relation<> > bm_type;
  63. bm_type bm = ba::list_of< bm_type::relation >(1,0.1)(2,0.2)(3,0.3);
  64. ba::insert( bm )(4,0.4)(5,0.5);
  65. ba::push_back( bm.right )(0.6,6)(0.7,7);
  66. ba::insert( bm.left )(8,0.8)(9,0.9);
  67. }
  68. }
  69. int test_main( int, char* [] )
  70. {
  71. test_bimap_assign();
  72. return 0;
  73. }