capacity.pass.cpp 1.0 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<bool>
  10. // size_type capacity() const;
  11. #include <vector>
  12. #include <cassert>
  13. #include "test_macros.h"
  14. #include "min_allocator.h"
  15. int main(int, char**)
  16. {
  17. {
  18. std::vector<bool> v;
  19. assert(v.capacity() == 0);
  20. }
  21. {
  22. std::vector<bool> v(100);
  23. assert(v.capacity() >= 100);
  24. v.push_back(0);
  25. assert(v.capacity() >= 101);
  26. }
  27. #if TEST_STD_VER >= 11
  28. {
  29. std::vector<bool, min_allocator<bool>> v;
  30. assert(v.capacity() == 0);
  31. }
  32. {
  33. std::vector<bool, min_allocator<bool>> v(100);
  34. assert(v.capacity() >= 100);
  35. v.push_back(0);
  36. assert(v.capacity() >= 101);
  37. }
  38. #endif
  39. return 0;
  40. }