#include <cassert>
#include <concepts>
#include <expected>
#include <type_traits>
#include <utility>
#include "test_macros.h"
#include "../../types.h"
template <class T>
concept HasValueNoexcept =
requires(T t) {
{ t.has_value() } noexcept;
};
struct Foo {};
static_assert(!HasValueNoexcept<Foo>);
static_assert(HasValueNoexcept<std::expected<int, int>>);
static_assert(HasValueNoexcept<const std::expected<int, int>>);
constexpr bool test() {
{
const std::expected<void, int> e;
assert(e.has_value());
}
{
const std::expected<void, int> e(std::unexpect, 5);
assert(!e.has_value());
}
{
const std::expected<void, TailClobberer<1>> e(std::unexpect);
#if !(defined(TEST_COMPILER_CLANG) && defined(_MSC_VER))
LIBCPP_STATIC_ASSERT(sizeof(TailClobberer<1>) == sizeof(e));
#endif
assert(!e.has_value());
}
return true;
}
int main(int, char**) {
test();
static_assert(test());
return 0;
}