libprimis icon indicating copy to clipboard operation
libprimis copied to clipboard

`std::optional` instead of `-1` indices

Open no-lex opened this issue 1 year ago • 2 comments

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 avatar Oct 19 '23 05:10 no-lex

Do you mind if I start tackling this?

Duskhorn avatar Nov 11 '23 09:11 Duskhorn

of course not

no-lex avatar Nov 11 '23 09:11 no-lex