dtor_noexcept.pass.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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>() // implied noexcept;
  10. // UNSUPPORTED: c++98, c++03
  11. #include <vector>
  12. #include <cassert>
  13. #include "test_macros.h"
  14. #include "test_allocator.h"
  15. template <class T>
  16. struct some_alloc
  17. {
  18. typedef T value_type;
  19. some_alloc(const some_alloc&);
  20. ~some_alloc() noexcept(false);
  21. };
  22. int main(int, char**)
  23. {
  24. {
  25. typedef std::vector<bool> C;
  26. static_assert(std::is_nothrow_destructible<C>::value, "");
  27. }
  28. {
  29. typedef std::vector<bool, test_allocator<bool>> C;
  30. static_assert(std::is_nothrow_destructible<C>::value, "");
  31. }
  32. {
  33. typedef std::vector<bool, other_allocator<bool>> C;
  34. static_assert(std::is_nothrow_destructible<C>::value, "");
  35. }
  36. #if defined(_LIBCPP_VERSION)
  37. {
  38. typedef std::vector<bool, some_alloc<bool>> C;
  39. static_assert(!std::is_nothrow_destructible<C>::value, "");
  40. }
  41. #endif // _LIBCPP_VERSION
  42. return 0;
  43. }