mirror of
https://github.com/Z3Prover/z3
synced 2026-01-24 11:04:00 +00:00
Adopt std::optional for try_get_value and try_get_size functions (#8268)
* Initial plan * Convert try_get_value and try_get_size to use std::optional Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Add unit tests for std::optional conversions and fix compilation error Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Address code review comments - improve readability and reduce code duplication Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
parent
2e7b700769
commit
1bb471447e
14 changed files with 92 additions and 44 deletions
|
|
@ -225,9 +225,8 @@ namespace api {
|
|||
e = m_bv_util.mk_numeral(n, s);
|
||||
}
|
||||
else if (fid == get_datalog_fid() && n.is_uint64()) {
|
||||
uint64_t sz;
|
||||
if (m_datalog_util.try_get_size(s, sz) &&
|
||||
sz <= n.get_uint64()) {
|
||||
if (auto size_opt = m_datalog_util.try_get_size(s);
|
||||
size_opt.has_value() && *size_opt <= n.get_uint64()) {
|
||||
invoke_error_handler(Z3_INVALID_ARG);
|
||||
}
|
||||
e = m_datalog_util.mk_numeral(n.get_uint64(), s);
|
||||
|
|
|
|||
|
|
@ -213,8 +213,11 @@ extern "C" {
|
|||
// must start logging here, since function uses Z3_get_sort_kind above
|
||||
LOG_Z3_get_finite_domain_sort_size(c, s, out);
|
||||
RESET_ERROR_CODE();
|
||||
VERIFY(mk_c(c)->datalog_util().try_get_size(to_sort(s), *out));
|
||||
return true;
|
||||
if (auto size = mk_c(c)->datalog_util().try_get_size(to_sort(s)); size) {
|
||||
*out = *size;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
Z3_CATCH_RETURN(false);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue