assign_copy.pass.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // <vector>
  9. // vector& operator=(const vector& c);
  10. #include <vector>
  11. #include <cassert>
  12. #include "test_macros.h"
  13. #include "test_allocator.h"
  14. #include "min_allocator.h"
  15. int main(int, char**)
  16. {
  17. {
  18. std::vector<bool, test_allocator<bool> > l(3, true, test_allocator<bool>(5));
  19. std::vector<bool, test_allocator<bool> > l2(l, test_allocator<bool>(3));
  20. l2 = l;
  21. assert(l2 == l);
  22. assert(l2.get_allocator() == test_allocator<bool>(3));
  23. }
  24. {
  25. std::vector<bool, other_allocator<bool> > l(3, true, other_allocator<bool>(5));
  26. std::vector<bool, other_allocator<bool> > l2(l, other_allocator<bool>(3));
  27. l2 = l;
  28. assert(l2 == l);
  29. assert(l2.get_allocator() == other_allocator<bool>(5));
  30. }
  31. #if TEST_STD_VER >= 11
  32. {
  33. std::vector<bool, min_allocator<bool> > l(3, true, min_allocator<bool>());
  34. std::vector<bool, min_allocator<bool> > l2(l, min_allocator<bool>());
  35. l2 = l;
  36. assert(l2 == l);
  37. assert(l2.get_allocator() == min_allocator<bool>());
  38. }
  39. #endif
  40. return 0;
  41. }