2010-09-03 23:46:37 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2010-11-16 23:09:02 +01:00
|
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
|
|
// Source Licenses. See LICENSE.TXT for details.
|
2010-09-03 23:46:37 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// <future>
|
|
|
|
|
2010-11-30 21:23:32 +01:00
|
|
|
// class future<R>
|
2010-09-03 23:46:37 +02:00
|
|
|
|
2010-11-30 21:23:32 +01:00
|
|
|
// shared_future<R> share() &&;
|
2010-09-03 23:46:37 +02:00
|
|
|
|
|
|
|
#include <future>
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
typedef int T;
|
|
|
|
std::promise<T> p;
|
|
|
|
std::future<T> f0 = p.get_future();
|
2010-11-30 21:23:32 +01:00
|
|
|
std::shared_future<T> f = std::move(f0.share());
|
2010-09-03 23:46:37 +02:00
|
|
|
assert(!f0.valid());
|
|
|
|
assert(f.valid());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
typedef int T;
|
|
|
|
std::future<T> f0;
|
2010-11-30 21:23:32 +01:00
|
|
|
std::shared_future<T> f = std::move(f0.share());
|
2010-09-03 23:46:37 +02:00
|
|
|
assert(!f0.valid());
|
|
|
|
assert(!f.valid());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
typedef int& T;
|
|
|
|
std::promise<T> p;
|
|
|
|
std::future<T> f0 = p.get_future();
|
2010-11-30 21:23:32 +01:00
|
|
|
std::shared_future<T> f = std::move(f0.share());
|
2010-09-03 23:46:37 +02:00
|
|
|
assert(!f0.valid());
|
|
|
|
assert(f.valid());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
typedef int& T;
|
|
|
|
std::future<T> f0;
|
2010-11-30 21:23:32 +01:00
|
|
|
std::shared_future<T> f = std::move(f0.share());
|
2010-09-03 23:46:37 +02:00
|
|
|
assert(!f0.valid());
|
|
|
|
assert(!f.valid());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
typedef void T;
|
|
|
|
std::promise<T> p;
|
|
|
|
std::future<T> f0 = p.get_future();
|
2010-11-30 21:23:32 +01:00
|
|
|
std::shared_future<T> f = std::move(f0.share());
|
2010-09-03 23:46:37 +02:00
|
|
|
assert(!f0.valid());
|
|
|
|
assert(f.valid());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
typedef void T;
|
|
|
|
std::future<T> f0;
|
2010-11-30 21:23:32 +01:00
|
|
|
std::shared_future<T> f = std::move(f0.share());
|
2010-09-03 23:46:37 +02:00
|
|
|
assert(!f0.valid());
|
|
|
|
assert(!f.valid());
|
|
|
|
}
|
|
|
|
}
|