move_assign_pass.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. // Copyright (C) 2011 Vicente J. Botet Escriba
  10. //
  11. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  12. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  13. // <future>
  14. // class shared_future<R>
  15. // shared_future& shared_future=(shared_future&& rhs);
  16. #define BOOST_THREAD_VERSION 3
  17. #include <boost/thread/future.hpp>
  18. #include <boost/detail/lightweight_test.hpp>
  19. boost::mutex m0;
  20. boost::mutex m1;
  21. int main()
  22. {
  23. {
  24. typedef int T;
  25. boost::promise<T> p;
  26. boost::shared_future<T> f0 = BOOST_THREAD_MAKE_RV_REF(p.get_future());
  27. boost::shared_future<T> f;
  28. f = boost::move(f0);
  29. BOOST_TEST(!f0.valid());
  30. BOOST_TEST(f.valid());
  31. }
  32. {
  33. typedef int T;
  34. boost::shared_future<T> f0;
  35. boost::shared_future<T> f;
  36. f = boost::move(f0);
  37. BOOST_TEST(!f0.valid());
  38. BOOST_TEST(!f.valid());
  39. }
  40. {
  41. typedef int& T;
  42. boost::promise<T> p;
  43. boost::shared_future<T> f0 = BOOST_THREAD_MAKE_RV_REF(p.get_future());
  44. boost::shared_future<T> f;
  45. f = boost::move(f0);
  46. BOOST_TEST(!f0.valid());
  47. BOOST_TEST(f.valid());
  48. }
  49. {
  50. typedef int& T;
  51. boost::shared_future<T> f0;
  52. boost::shared_future<T> f;
  53. f = boost::move(f0);
  54. BOOST_TEST(!f0.valid());
  55. BOOST_TEST(!f.valid());
  56. }
  57. {
  58. typedef void T;
  59. boost::promise<T> p;
  60. boost::shared_future<T> f0 = BOOST_THREAD_MAKE_RV_REF(p.get_future());
  61. boost::shared_future<T> f;
  62. f = boost::move(f0);
  63. BOOST_TEST(!f0.valid());
  64. BOOST_TEST(f.valid());
  65. }
  66. {
  67. typedef void T;
  68. boost::shared_future<T> f0;
  69. boost::shared_future<T> f;
  70. f = boost::move(f0);
  71. BOOST_TEST(!f0.valid());
  72. BOOST_TEST(!f.valid());
  73. }
  74. return boost::report_errors();
  75. }