-
Notifications
You must be signed in to change notification settings - Fork 277
Add optional_lookup utility function #3473
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
Add optional_lookup utility function #3473
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, would be nice to generalise it to use std::find
in the general case. Then a specialisation for containers that implement their own find
function.
@xbauch Thought about it, wasn't completely sure if it was a good idea because for most containers the result should be |
98e0a72
to
5139616
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: 5139616).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/92738933
Interesting. To follow on from @xbauch 's comment - it seems that as a generic problem, this becomes quite non-trivial. In the non generic scenairo an overload for std::map or other known types. These guys, who quite definitely know what they're doing - found a simple edge case, that seemed surprisingly hard to get right: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This strictly needs a unit test. At present, we don't even know whether this is syntactically acceptable to all our compilers used in CI.
src/util/optional_utils.h
Outdated
#include "optional.h" | ||
|
||
#include <iterator> | ||
#include <map> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are those includes required here?
5139616
to
ae28e72
Compare
@tautschnig Removed vestigial includes and added a unit test |
7f0a3c4
to
4e506bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: 4e506bc).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/93002859
This provides a more ergonomic interface over map::find
4e506bc
to
fa39d19
Compare
CodeBuild failure due to spurious network issues, restarting CI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Passed Diffblue compatibility checks (cbmc commit: fa39d19).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/93043043
This provides a more ergonomic interface over map::find for the case when you don't need an iterator