brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · bce3410 Raw
45 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// UNSUPPORTED: no-threads10// UNSUPPORTED: c++03, c++11, c++1411 12// <future>13 14// class future_error15//16// explicit future_error(future_errc e); // since C++1717 18#include <cassert>19#include <future>20#include <type_traits>21 22int main(int, char**) {23  {24    std::future_error f(std::future_errc::broken_promise);25    assert(f.code() == std::make_error_code(std::future_errc::broken_promise));26  }27  {28    std::future_error f(std::future_errc::future_already_retrieved);29    assert(f.code() == std::make_error_code(std::future_errc::future_already_retrieved));30  }31  {32    std::future_error f(std::future_errc::promise_already_satisfied);33    assert(f.code() == std::make_error_code(std::future_errc::promise_already_satisfied));34  }35  {36    std::future_error f(std::future_errc::no_state);37    assert(f.code() == std::make_error_code(std::future_errc::no_state));38  }39 40  // Make sure the constructor is explicit41  static_assert(!std::is_convertible_v<std::future_errc, std::future_error>);42 43  return 0;44}45