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

Empty handle #22

Open
glennhickey opened this issue May 23, 2019 · 5 comments
Open

Empty handle #22

glennhickey opened this issue May 23, 2019 · 5 comments

Comments

@glennhickey
Copy link
Contributor

This is probably a dumb question, but what's the best way to check if a handle is empty? This comes up, for example, when replacing code of the type

Node* node = nullptr;
// do some stuff
if (node != nullptr) {
   // more stuff
}

Obviously, I can do the same thing with a handle_t*, but that's pretty ugly. I'd rather use handle_t directly. Is there a way to do this?

@ekg
Copy link
Member

ekg commented May 23, 2019 via email

@glennhickey
Copy link
Contributor Author

glennhickey commented May 23, 2019 via email

@glennhickey
Copy link
Contributor Author

I'll just add, this seems like a hole in the interface. Is it unreasonable to have a null_handle constant value somewhere and ask all implementations to never use it for a valid handle? Adding this wouldn't affect existing client code nor, I suspect, most graph implementations.

@ekg
Copy link
Member

ekg commented May 23, 2019 via email

@glennhickey
Copy link
Contributor Author

I think the fact that we can declare all these handles without initializing them means we should be able to check if they're null/empty. For regular handle's I was just thinking something simple as #23.

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

2 participants