brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · c00d0df Raw
37 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: c++03, c++11, c++14, c++17, c++2010 11// constexpr explicit expected(in_place_t) noexcept;12 13#include <cassert>14#include <expected>15#include <type_traits>16#include <utility>17 18// test explicit19static_assert(std::is_constructible_v<std::expected<void, int>, std::in_place_t>);20static_assert(!std::is_convertible_v<std::in_place_t, std::expected<void, int>>);21 22// test noexcept23static_assert(std::is_nothrow_constructible_v<std::expected<void, int>, std::in_place_t>);24 25constexpr bool test() {26  std::expected<void, int> e(std::in_place);27  assert(e.has_value());28 29  return true;30}31 32int main(int, char**) {33  test();34  static_assert(test());35  return 0;36}37