move_noexcept.pass.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. // <string>
  10. // basic_string(basic_string&&)
  11. // noexcept(is_nothrow_move_constructible<allocator_type>::value);
  12. // This tests a conforming extension
  13. #include <string>
  14. #include <cassert>
  15. #include "test_macros.h"
  16. #include "test_allocator.h"
  17. template <class T>
  18. struct some_alloc
  19. {
  20. typedef T value_type;
  21. some_alloc(const some_alloc&);
  22. };
  23. int main()
  24. {
  25. #if __has_feature(cxx_noexcept)
  26. {
  27. typedef std::string C;
  28. static_assert(std::is_nothrow_move_constructible<C>::value, "");
  29. }
  30. {
  31. typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
  32. static_assert(std::is_nothrow_move_constructible<C>::value, "");
  33. }
  34. {
  35. typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
  36. #if TEST_STD_VER <= 14
  37. static_assert(!std::is_nothrow_move_constructible<C>::value, "");
  38. #else
  39. static_assert( std::is_nothrow_move_constructible<C>::value, "");
  40. #endif
  41. }
  42. #endif
  43. }