3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-07-20 22:15:49 +00:00

[WIP] Find and update std::optional usage in code base (#8272)

* Initial plan

* Add try_get_value for std::map and use it in var_register.h and dioph_eq.cpp

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Add try_get_value overload for unordered_map with custom hash and use in lar_solver.cpp

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Remove redundant try_get_value template overload

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Remove std::map include and try_get_value overload from lp_utils.h

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:
Copilot 2026-01-21 19:55:36 -08:00 committed by GitHub
parent b0313ca80a
commit c392592831
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 47 additions and 47 deletions

View file

@ -52,8 +52,8 @@ std::ostream& print_vector(const C * t, unsigned size, std::ostream & out) {
}
template <typename A, typename B>
std::optional<B> try_get_value(const std::unordered_map<A,B> & map, const A& key) {
template <typename A, typename B, typename Hash = std::hash<A>, typename KeyEqual = std::equal_to<A>>
std::optional<B> try_get_value(const std::unordered_map<A,B,Hash,KeyEqual> & map, const A& key) {
const auto it = map.find(key);
if (it == map.end())
return std::nullopt;