move_ctor_pass.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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&& rhs);
  16. #define BOOST_THREAD_VERSION 3
  17. #include <boost/thread/future.hpp>
  18. #include <boost/detail/lightweight_test.hpp>
  19. boost::mutex m;
  20. int main()
  21. {
  22. {
  23. typedef int T;
  24. boost::promise<T> p;
  25. boost::shared_future<T> f0 = BOOST_THREAD_MAKE_RV_REF(p.get_future());
  26. boost::shared_future<T> f = boost::move(f0);
  27. BOOST_TEST(!f0.valid());
  28. BOOST_TEST(f.valid());
  29. }
  30. {
  31. typedef int T;
  32. boost::shared_future<T> f0;
  33. boost::shared_future<T> f = boost::move(f0);
  34. BOOST_TEST(!f0.valid());
  35. BOOST_TEST(!f.valid());
  36. }
  37. {
  38. typedef int& T;
  39. boost::promise<T> p;
  40. boost::shared_future<T> f0 = BOOST_THREAD_MAKE_RV_REF(p.get_future());
  41. boost::shared_future<T> f = boost::move(f0);
  42. BOOST_TEST(!f0.valid());
  43. BOOST_TEST(f.valid());
  44. }
  45. {
  46. typedef int& T;
  47. boost::shared_future<T> f0;
  48. boost::shared_future<T> f = boost::move(f0);
  49. BOOST_TEST(!f0.valid());
  50. BOOST_TEST(!f.valid());
  51. }
  52. {
  53. typedef void T;
  54. boost::promise<T> p;
  55. boost::shared_future<T> f0 = BOOST_THREAD_MAKE_RV_REF(p.get_future());
  56. boost::shared_future<T> f = boost::move(f0);
  57. BOOST_TEST(!f0.valid());
  58. BOOST_TEST(f.valid());
  59. }
  60. {
  61. typedef void T;
  62. boost::shared_future<T> f0;
  63. boost::shared_future<T> f = boost::move(f0);
  64. BOOST_TEST(!f0.valid());
  65. BOOST_TEST(!f.valid());
  66. }
  67. return boost::report_errors();
  68. }