Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Jonathan Roelofs | 8d86b2e | 2014-09-05 19:45:05 +0000 | [diff] [blame] | 9 | // |
| 10 | // UNSUPPORTED: libcpp-has-no-threads |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 11 | |
| 12 | // <future> |
| 13 | |
| 14 | // enum class launch |
| 15 | // { |
Howard Hinnant | 6689564 | 2010-11-23 18:33:54 +0000 | [diff] [blame] | 16 | // async = 1, |
| 17 | // deferred = 2, |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 18 | // any = async | deferred |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 19 | // }; |
| 20 | |
| 21 | #include <future> |
Howard Hinnant | f491e51 | 2013-06-29 18:38:17 +0000 | [diff] [blame] | 22 | #include <cassert> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 23 | |
| 24 | int main() |
| 25 | { |
Howard Hinnant | f491e51 | 2013-06-29 18:38:17 +0000 | [diff] [blame] | 26 | #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 27 | static_assert(static_cast<int>(std::launch::any) == |
Howard Hinnant | f6d875f | 2011-12-02 19:36:40 +0000 | [diff] [blame] | 28 | (static_cast<int>(std::launch::async) | static_cast<int>(std::launch::deferred)), ""); |
Howard Hinnant | f491e51 | 2013-06-29 18:38:17 +0000 | [diff] [blame] | 29 | #else |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 30 | static_assert(std::launch::any == (std::launch::async | std::launch::deferred), ""); |
Howard Hinnant | f491e51 | 2013-06-29 18:38:17 +0000 | [diff] [blame] | 31 | static_assert(std::launch(0) == (std::launch::async & std::launch::deferred), ""); |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 32 | static_assert(std::launch::any == (std::launch::async ^ std::launch::deferred), ""); |
Howard Hinnant | 6a683bf | 2013-07-02 18:01:41 +0000 | [diff] [blame] | 33 | static_assert(std::launch::deferred == ~std::launch::async, ""); |
Howard Hinnant | f491e51 | 2013-06-29 18:38:17 +0000 | [diff] [blame] | 34 | std::launch x = std::launch::async; |
| 35 | x &= std::launch::deferred; |
| 36 | assert(x == std::launch(0)); |
| 37 | x = std::launch::async; |
| 38 | x |= std::launch::deferred; |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 39 | assert(x == std::launch::any); |
Howard Hinnant | f491e51 | 2013-06-29 18:38:17 +0000 | [diff] [blame] | 40 | x ^= std::launch::deferred; |
| 41 | assert(x == std::launch::async); |
| 42 | #endif |
Howard Hinnant | f6d875f | 2011-12-02 19:36:40 +0000 | [diff] [blame] | 43 | static_assert(static_cast<int>(std::launch::async) == 1, ""); |
| 44 | static_assert(static_cast<int>(std::launch::deferred) == 2, ""); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 45 | } |