db_cfront.pass.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. // <string>
  9. // Call front() on empty const container.
  10. #if _LIBCPP_DEBUG >= 1
  11. #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
  12. #include <string>
  13. #include <cassert>
  14. #include <iterator>
  15. #include <exception>
  16. #include <cstdlib>
  17. #include "test_macros.h"
  18. #include "min_allocator.h"
  19. int main(int, char**)
  20. {
  21. {
  22. typedef std::string S;
  23. const S s;
  24. assert(s.front() == 0);
  25. assert(false);
  26. }
  27. #if TEST_STD_VER >= 11
  28. {
  29. typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
  30. const S s;
  31. assert(s.front() == 0);
  32. assert(false);
  33. }
  34. #endif
  35. }
  36. #else
  37. int main(int, char**)
  38. {
  39. return 0;
  40. }
  41. #endif