On Thursday, 1 July 2021 at 20:23:41 UTC, Ben Jones wrote:
I tried to to write 2 versions of opIndex:

```
public Type opIndex(IndexType x) const {... }
//and
private Type ref opIndex(IndexType x) { ... }
```

which doesn't seem to work because client code that has a non-const reference to my container tries to use the private non-const version and triggers a `not accessible` error. Is there a way to do this with overloads, or will I need to just pick a different name for the private version?

Overload resolution does not take visibility (i.e., `private`) into account. So yes, you will have to pick a different name for the private version.

Reply via email to