move_noexcept.pass.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. // UNSUPPORTED: c++98, c++03
  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. int main(int, char**)
  18. {
  19. {
  20. typedef std::string C;
  21. static_assert(std::is_nothrow_move_constructible<C>::value, "");
  22. }
  23. {
  24. typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
  25. static_assert(std::is_nothrow_move_constructible<C>::value, "");
  26. }
  27. {
  28. typedef std::basic_string<char, std::char_traits<char>, limited_allocator<char, 10>> C;
  29. #if TEST_STD_VER <= 14
  30. static_assert(!std::is_nothrow_move_constructible<C>::value, "");
  31. #else
  32. static_assert( std::is_nothrow_move_constructible<C>::value, "");
  33. #endif
  34. }
  35. return 0;
  36. }