container_tests11a.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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_begin(data);
  45. test_clear(data);
  46. test_empty(data);
  47. test_end(data);
  48. test_set_erase(data);
  49. test_get_allocator(data);
  50. return boost::report_errors();
  51. }