move_ctor.pass.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. //
  9. // UNSUPPORTED: libcpp-has-no-threads
  10. // UNSUPPORTED: c++98, c++03, c++11
  11. // XFAIL: dylib-has-no-shared_mutex
  12. // <shared_mutex>
  13. // template <class Mutex> class shared_lock;
  14. // shared_lock(shared_lock&& u);
  15. #include <shared_mutex>
  16. #include <cassert>
  17. #include "nasty_containers.hpp"
  18. int main(int, char**)
  19. {
  20. {
  21. typedef std::shared_timed_mutex M;
  22. M m;
  23. std::shared_lock<M> lk0(m);
  24. std::shared_lock<M> lk = std::move(lk0);
  25. assert(lk.mutex() == std::addressof(m));
  26. assert(lk.owns_lock() == true);
  27. assert(lk0.mutex() == nullptr);
  28. assert(lk0.owns_lock() == false);
  29. }
  30. {
  31. typedef nasty_mutex M;
  32. M m;
  33. std::shared_lock<M> lk0(m);
  34. std::shared_lock<M> lk = std::move(lk0);
  35. assert(lk.mutex() == std::addressof(m));
  36. assert(lk.owns_lock() == true);
  37. assert(lk0.mutex() == nullptr);
  38. assert(lk0.owns_lock() == false);
  39. }
  40. return 0;
  41. }