container_tests11b.cpp 1.8 KB

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