diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:47:26 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:47:26 +0000 |
| commit | 51072bd6bf79ef2bc6a922079bff57c31c1effbc (patch) | |
| tree | 91a2effbc9e6f80bdbbf9eb70e06c51ad0867ea0 /test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp | |
| parent | bb5e33f003797b67974a8893f7f2930fc51b8210 (diff) | |
Notes
Diffstat (limited to 'test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp')
| -rw-r--r-- | test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp b/test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp new file mode 100644 index 000000000000..7fafd1005649 --- /dev/null +++ b/test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp @@ -0,0 +1,64 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 + +// <future> + +// class packaged_task<R(ArgTypes...)> + +// ~packaged_task(); + +#include <future> +#include <cassert> + +class A +{ + long data_; + +public: + explicit A(long i) : data_(i) {} + + long operator()(long i, long j) const {return data_ + i + j;} +}; + +void func(std::packaged_task<double(int, char)> p) +{ +} + +void func2(std::packaged_task<double(int, char)> p) +{ + p(3, 'a'); +} + +int main() +{ + { + std::packaged_task<double(int, char)> p(A(5)); + std::future<double> f = p.get_future(); + std::thread(func, std::move(p)).detach(); + try + { + double i = f.get(); + assert(false); + } + catch (const std::future_error& e) + { + assert(e.code() == make_error_code(std::future_errc::broken_promise)); + } + } + { + std::packaged_task<double(int, char)> p(A(5)); + std::future<double> f = p.get_future(); + std::thread(func2, std::move(p)).detach(); + assert(f.get() == 105.0); + } +} |
