dtor_noexcept.pass.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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_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()
  23. {
  24. {
  25. typedef std::string C;
  26. static_assert(std::is_nothrow_destructible<C>::value, "");
  27. }
  28. {
  29. typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
  30. static_assert(std::is_nothrow_destructible<C>::value, "");
  31. }
  32. {
  33. typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
  34. static_assert(!std::is_nothrow_destructible<C>::value, "");
  35. }
  36. }