Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc++][test] Mark optional test functions as TEST_CONSTEXPR_CXX20 #94172

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,15 @@ void test_on_test_type() {
}
}

constexpr bool test_empty_emplace()
{
optional<const int> opt;
auto &v = opt.emplace(42);
static_assert( std::is_same_v<const int&, decltype(v)>, "" );
assert(*opt == 42);
assert( v == 42);
opt.emplace();
assert(*opt == 0);
return true;
TEST_CONSTEXPR_CXX20 bool test_empty_emplace() {
optional<const int> opt;
auto& v = opt.emplace(42);
static_assert(std::is_same_v<const int&, decltype(v)>, "");
assert(*opt == 42);
assert(v == 42);
opt.emplace();
assert(*opt == 0);
return true;
}

int main(int, char**)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,19 @@ struct X

bool X::dtor_called = false;

constexpr bool check_reset()
{
{
optional<int> opt;
static_assert(noexcept(opt.reset()) == true, "");
opt.reset();
assert(static_cast<bool>(opt) == false);
}
{
optional<int> opt(3);
opt.reset();
assert(static_cast<bool>(opt) == false);
}
return true;
TEST_CONSTEXPR_CXX20 bool check_reset() {
{
optional<int> opt;
static_assert(noexcept(opt.reset()) == true, "");
opt.reset();
assert(static_cast<bool>(opt) == false);
}
{
optional<int> opt(3);
opt.reset();
assert(static_cast<bool>(opt) == false);
}
return true;
}

int main(int, char**)
Expand Down
Loading