brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · b08ffce 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: c++03, c++11, c++14, c++17, c++2010 11// constexpr void operator*() const & noexcept;12 13#include <cassert>14#include <concepts>15#include <expected>16#include <type_traits>17#include <utility>18 19#include "test_macros.h"20 21// Test noexcept22template <class T>23concept DerefNoexcept =24    requires(T t) {25      { std::forward<T>(t).operator*() } noexcept;26    };27 28static_assert(!DerefNoexcept<int>);29 30static_assert(DerefNoexcept<std::expected<void, int>>);31 32constexpr bool test() {33  const std::expected<void, int> e;34  *e;35  static_assert(std::is_same_v<decltype(*e), void>);36 37  return true;38}39 40int main(int, char**) {41  test();42  static_assert(test());43  return 0;44}45