Home | History | Annotate | Download | only in futures.unique_future
      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 //
     10 // UNSUPPORTED: libcpp-has-no-threads
     11 
     12 // <future>
     13 
     14 // class future<R>
     15 
     16 // future(future&& rhs);
     17 
     18 #include <future>
     19 #include <cassert>
     20 
     21 int main()
     22 {
     23 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
     24     {
     25         typedef int T;
     26         std::promise<T> p;
     27         std::future<T> f0 = p.get_future();
     28         std::future<T> f = std::move(f0);
     29         assert(!f0.valid());
     30         assert(f.valid());
     31     }
     32     {
     33         typedef int T;
     34         std::future<T> f0;
     35         std::future<T> f = std::move(f0);
     36         assert(!f0.valid());
     37         assert(!f.valid());
     38     }
     39     {
     40         typedef int& T;
     41         std::promise<T> p;
     42         std::future<T> f0 = p.get_future();
     43         std::future<T> f = std::move(f0);
     44         assert(!f0.valid());
     45         assert(f.valid());
     46     }
     47     {
     48         typedef int& T;
     49         std::future<T> f0;
     50         std::future<T> f = std::move(f0);
     51         assert(!f0.valid());
     52         assert(!f.valid());
     53     }
     54     {
     55         typedef void T;
     56         std::promise<T> p;
     57         std::future<T> f0 = p.get_future();
     58         std::future<T> f = std::move(f0);
     59         assert(!f0.valid());
     60         assert(f.valid());
     61     }
     62     {
     63         typedef void T;
     64         std::future<T> f0;
     65         std::future<T> f = std::move(f0);
     66         assert(!f0.valid());
     67         assert(!f.valid());
     68     }
     69 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
     70 }
     71