brace_assignment.pass.cpp 871 B

12345678910111213141516171819202122232425262728293031323334353637
  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<charT,traits,Allocator>&
  11. // operator=(basic_string<charT,traits,Allocator>&& str);
  12. #include <string>
  13. #include <cassert>
  14. #include "test_macros.h"
  15. int main(int, char**)
  16. {
  17. // Test that assignment from {} and {ptr, len} are allowed and are not
  18. // ambiguous.
  19. {
  20. std::string s = "hello world";
  21. s = {};
  22. assert(s.empty());
  23. }
  24. {
  25. std::string s = "hello world";
  26. s = {"abc", 2};
  27. assert(s == "ab");
  28. }
  29. return 0;
  30. }