Home | History | Annotate | Download | only in futures.overview
      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 // enum class launch
     15 // {
     16 //     async = 1,
     17 //     deferred = 2,
     18 //     any = async | deferred /* EXTENSION */
     19 // };
     20 
     21 #include <future>
     22 #include <cassert>
     23 
     24 #include "test_macros.h"
     25 
     26 int main()
     27 {
     28 #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
     29    LIBCPP_STATIC_ASSERT(static_cast<int>(std::launch::any) ==
     30                  (static_cast<int>(std::launch::async) | static_cast<int>(std::launch::deferred)), "");
     31 #else
     32     LIBCPP_STATIC_ASSERT(std::launch::any == (std::launch::async | std::launch::deferred), "");
     33     static_assert(std::launch(0) == (std::launch::async & std::launch::deferred), "");
     34     LIBCPP_STATIC_ASSERT(std::launch::any == (std::launch::async ^ std::launch::deferred), "");
     35     LIBCPP_STATIC_ASSERT(std::launch::deferred == ~std::launch::async, "");
     36     std::launch x = std::launch::async;
     37     x &= std::launch::deferred;
     38     assert(x == std::launch(0));
     39     x = std::launch::async;
     40     x |= std::launch::deferred;
     41     LIBCPP_ASSERT(x == std::launch::any);
     42     x ^= std::launch::deferred;
     43     assert(x == std::launch::async);
     44 #endif
     45     static_assert(static_cast<int>(std::launch::async) == 1, "");
     46     static_assert(static_cast<int>(std::launch::deferred) == 2, "");
     47 }
     48