empty.pass.cpp 1004 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. // class vector
  10. // bool empty() const noexcept;
  11. #include <vector>
  12. #include <cassert>
  13. #include "test_macros.h"
  14. #include "min_allocator.h"
  15. int main(int, char**)
  16. {
  17. {
  18. typedef std::vector<bool> C;
  19. C c;
  20. ASSERT_NOEXCEPT(c.empty());
  21. assert(c.empty());
  22. c.push_back(false);
  23. assert(!c.empty());
  24. c.clear();
  25. assert(c.empty());
  26. }
  27. #if TEST_STD_VER >= 11
  28. {
  29. typedef std::vector<bool, min_allocator<bool>> C;
  30. C c;
  31. ASSERT_NOEXCEPT(c.empty());
  32. assert(c.empty());
  33. c.push_back(false);
  34. assert(!c.empty());
  35. c.clear();
  36. assert(c.empty());
  37. }
  38. #endif
  39. return 0;
  40. }