[NFC] Make SortedVector inherit privately from std::vector - #9171
Conversation
There was a problem hiding this comment.
Seems like push_back and resize should not be exposed publicly since they will also break invariants. Maybe make this into a class and have a public block?
There was a problem hiding this comment.
Fixed the handling of those two cases, good catch.
I don't feel a class/public block would be clearer, but let me know what you think.
There was a problem hiding this comment.
In general I'd prefer class for something like this, since it's not a POD type and it does have behavior that we want to hide. I think 'private by default' is the safer option especially since we were already exposing methods that we shouldn't have. But not a big deal to me since this is a small codebase and there's not much chance of misuse.
There was a problem hiding this comment.
Yeah, I see what you're saying. Our convention has been otherwise, so I'd rather not go against it, but I'm open to us deciding some day to change the convention here to the safer approach.
This prohibits referring to a SortedVector using an upcast, as the
upcast might manipulate the contents in a non-sorted way.