container_tests3a.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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::vector<int> const init_vector()
  23. {
  24. typedef std::vector<int> int_vector;
  25. int const data[] = { -4, -3, -2, -1, 0 };
  26. int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]);
  27. return int_vector(data, data + data_size);
  28. }
  29. std::vector<int> const build_vector()
  30. {
  31. typedef std::vector<int> int_vector;
  32. static int_vector data = init_vector();
  33. int_vector::size_type const size = data.size();
  34. int_vector::iterator it = data.begin();
  35. int_vector::iterator const end = data.end();
  36. for (; it != end; ++it)
  37. *it += size;
  38. return data;
  39. }
  40. int
  41. main()
  42. {
  43. BOOST_STATIC_ASSERT((phx::stl::has_mapped_type<std::map<int, int> >::value));
  44. BOOST_STATIC_ASSERT((phx::stl::has_key_type<std::map<int, int> >::value));
  45. std::map<int, int> const data = build_map();
  46. test_begin(data);
  47. test_clear(data);
  48. test_empty(data);
  49. test_end(data);
  50. test_map_erase(data);
  51. test_get_allocator(data);
  52. return boost::report_errors();
  53. }