dtor_noexcept.pass.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // UNSUPPORTED: c++98, c++03
  10. // <string>
  11. // ~basic_string() // implied noexcept;
  12. #include <string>
  13. #include <cassert>
  14. #include "test_macros.h"
  15. #include "test_allocator.h"
  16. template <class T>
  17. struct some_alloc
  18. {
  19. typedef T value_type;
  20. some_alloc(const some_alloc&);
  21. ~some_alloc() noexcept(false);
  22. };
  23. int main()
  24. {
  25. {
  26. typedef std::string C;
  27. static_assert(std::is_nothrow_destructible<C>::value, "");
  28. }
  29. {
  30. typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
  31. static_assert(std::is_nothrow_destructible<C>::value, "");
  32. }
  33. {
  34. typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
  35. LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible<C>::value, "");
  36. }
  37. }