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

provide checked form of vertex/edge property access method #322

Open
zhuoqiang opened this issue Jan 9, 2023 · 0 comments
Open

provide checked form of vertex/edge property access method #322

zhuoqiang opened this issue Jan 9, 2023 · 0 comments

Comments

@zhuoqiang
Copy link

in stl, there are both checked and unchecked method to access the value from container

vector[0]; // unchecked, may UB
vector.at(1); // checked, may throw

map["key1"]; // auto add missing key
map.at("key2"); // checked, may throw

graph as a container, however, does not provide a checked method to access the vertex/edge property using vertex/edge id

graph[vertex_id]; // unchecked, may UB
graph[edge_id]; // unchecked, may UB

How about providing a checked access method that throw exception in case of missing id. Also helps to keep the API consist with STL containers

graph.at(vertex_id); // unchecked, may throw
graph.at(edge_id); // unchecked, may throw

and in general, not sure if I missed it but could not find API to check if the id is valid or not:

graph.contains(vertex_id); // not sure if it exists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant