/Src/Dependencies/Boost/libs/phoenix/test/container/container_tests6b.cpp

http://hadesmem.googlecode.com/ · C++ · 70 lines · 54 code · 10 blank · 6 comment · 4 complexity · 071610dbad3b804d4559cd429a0933f0 MD5 · raw file

  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. std::multimap<int, int> const data = build_multimap();
  51. test_multimap_insert(data);
  52. test_key_comp(data);
  53. test_max_size(data);
  54. test_rbegin(data);
  55. test_rend(data);
  56. test_size(data);
  57. test_value_comp(data);
  58. return boost::report_errors();
  59. }