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. // UNSUPPORTED: c++98, c++03
  10. // <string>
  11. // basic_string(basic_string&&)
  12. // noexcept(is_nothrow_move_constructible<allocator_type>::value);
  13. // This tests a conforming extension
  14. #include <string>
  15. #include <cassert>
  16. #include "test_macros.h"
  17. #include "test_allocator.h"
  18. template <class T>
  19. struct some_alloc
  20. {
  21. typedef T value_type;
  22. some_alloc(const some_alloc&);
  23. };
  24. int main()
  25. {
  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. }