container_tests6b.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*=============================================================================
  2. Copyright (c) 2004 Angus Leeming
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #include "container_tests.hpp"
  7. #include <boost/static_assert.hpp>
  8. std::map<int, int> const build_map()
  9. {
  10. typedef std::map<int, int> int_map;
  11. typedef std::vector<int> int_vector;
  12. int_map result;
  13. int_vector const data = build_vector();
  14. int_vector::const_iterator it = data.begin();
  15. int_vector::const_iterator const end = data.end();
  16. for (; it != end; ++it) {
  17. int const value = *it;
  18. result[value] = 100 * value;
  19. }
  20. return result;
  21. }
  22. std::multimap<int, int> const build_multimap()
  23. {
  24. typedef std::map<int, int> int_map;
  25. typedef std::multimap<int, int> int_multimap;
  26. int_map const data = build_map();
  27. return int_multimap(data.begin(), data.end());
  28. }
  29. std::vector<int> const init_vector()
  30. {
  31. typedef std::vector<int> int_vector;
  32. int const data[] = { -4, -3, -2, -1, 0 };
  33. int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]);
  34. return int_vector(data, data + data_size);
  35. }
  36. std::vector<int> const build_vector()
  37. {
  38. typedef std::vector<int> int_vector;
  39. static int_vector data = init_vector();
  40. int_vector::size_type const size = data.size();
  41. int_vector::iterator it = data.begin();
  42. int_vector::iterator const end = data.end();
  43. for (; it != end; ++it)
  44. *it += size;
  45. return data;
  46. }
  47. int
  48. main()
  49. {
  50. BOOST_STATIC_ASSERT((phx::stl::has_mapped_type<std::multimap<int, int> >::value));
  51. BOOST_STATIC_ASSERT((phx::stl::has_key_type<std::multimap<int, int> >::value));
  52. std::multimap<int, int> const data = build_multimap();
  53. test_multimap_insert(data);
  54. test_key_comp(data);
  55. test_max_size(data);
  56. test_rbegin(data);
  57. test_rend(data);
  58. test_size(data);
  59. test_value_comp(data);
  60. return boost::report_errors();
  61. }