diff options
author | Eric Fiselier <eric@efcs.ca> | 2015-08-28 05:06:04 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2015-08-28 05:06:04 +0000 |
commit | 031a3d203ab2795050492d71da44179939b42bb3 (patch) | |
tree | 29b62b6cdf4c74a8f37fc55544a3f7ed8d30c492 /test/std/thread/futures/futures.promise/move_ctor.pass.cpp | |
parent | 5ec04a92d24061c5332c2989bce999a5414d9d83 (diff) | |
download | external_libcxx-031a3d203ab2795050492d71da44179939b42bb3.tar.gz external_libcxx-031a3d203ab2795050492d71da44179939b42bb3.tar.bz2 external_libcxx-031a3d203ab2795050492d71da44179939b42bb3.zip |
[libcxx] Mark most test/std/future tests as UNSUPPORTED in C++03
Summary:
This patch marks *most* tests for `std::promise`, `std::future` and `std::shared_future` as unsupported in C++03. These tests fail in C++03 mode because they attempt to copy a `std::future` even though it is a `MoveOnly` type. AFAIK the missing move-semantics in `std::future` is the only reason these tests fail but without move semantics these classes are useless. For example even though `std::promise::set_value` and `std::promise::set_exception(...)` work in C++03 `std::promise` is still useless because we cannot call `std::promise::get_future(...)`.
It might be possible to hack `std::move(...)` like we do for `std::unique_ptr` to make the move semantics work but I don't think it is worth the effort. Instead I think we should leave the `<future>` header as-is and mark the failing tests as `UNSUPPORTED`. I don't believe there are any users of `std::future` or `std::promise` in C++03 because they are so unusable. Therefore I am not concerned about losing test coverage and possibly breaking users. However because there are still parts of `<future>` that work in C++03 it would be wrong to `#ifdef` out the entire header.
@mclow.lists Should we take further steps to prevent the use of `std::promise`, `std::future` and `std::shared_future` in C++03?
Note: This patch also cleans up the tests and converts them to use `support/test_allocator.h` instead of a duplicate class in `test/std/futures/test_allocator.h`.
Reviewers: mclow.lists
Subscribers: vsk, mclow.lists, cfe-commits
Differential Revision: http://reviews.llvm.org/D12135
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@246271 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/std/thread/futures/futures.promise/move_ctor.pass.cpp')
-rw-r--r-- | test/std/thread/futures/futures.promise/move_ctor.pass.cpp | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/test/std/thread/futures/futures.promise/move_ctor.pass.cpp b/test/std/thread/futures/futures.promise/move_ctor.pass.cpp index eeec4fb15..d45c48a95 100644 --- a/test/std/thread/futures/futures.promise/move_ctor.pass.cpp +++ b/test/std/thread/futures/futures.promise/move_ctor.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // <future> @@ -18,18 +19,17 @@ #include <future> #include <cassert> -#include "../test_allocator.h" +#include "test_allocator.h" int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { std::promise<int> p0(std::allocator_arg, test_allocator<int>()); std::promise<int> p(std::move(p0)); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); std::future<int> f = p.get_future(); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); try { @@ -40,15 +40,15 @@ int main() { assert(e.code() == make_error_code(std::future_errc::no_state)); } - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { std::promise<int&> p0(std::allocator_arg, test_allocator<int>()); std::promise<int&> p(std::move(p0)); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); std::future<int&> f = p.get_future(); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); try { @@ -59,15 +59,15 @@ int main() { assert(e.code() == make_error_code(std::future_errc::no_state)); } - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { std::promise<void> p0(std::allocator_arg, test_allocator<void>()); std::promise<void> p(std::move(p0)); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); std::future<void> f = p.get_future(); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); try { @@ -78,8 +78,7 @@ int main() { assert(e.code() == make_error_code(std::future_errc::no_state)); } - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); } - assert(test_alloc_base::count == 0); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + assert(test_alloc_base::alloc_count == 0); } |