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

std::optional instead of -1 indices #268

Open
no-lex opened this issue Oct 19, 2023 · 2 comments
Open

std::optional instead of -1 indices #268

no-lex opened this issue Oct 19, 2023 · 2 comments
Labels
misimplementation Circumlocutious or redundant implementation

Comments

@no-lex
Copy link
Member

no-lex commented Oct 19, 2023

Using -1 for an invalid index is not very safe and also not necessary due to the existence of std::optional. With std::optional it should be possible to at least use size_t indices, the appropriate type for the indices of e.g. a vector, if not std::optional<std::vector<>::iterator>. Many parts of the codebase involve a data structure containing integral indices referring to another data structure, and while this is not good design, moving to std::optional would be a step in the right direction.

@no-lex no-lex added the misimplementation Circumlocutious or redundant implementation label Oct 19, 2023
@Duskhorn
Copy link
Contributor

Do you mind if I start tackling this?

@no-lex
Copy link
Member Author

no-lex commented Nov 11, 2023

of course not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
misimplementation Circumlocutious or redundant implementation
Projects
None yet
Development

No branches or pull requests

2 participants