Closed frederick-vs-ja closed 2 years ago
I feel I was wrong. It may be unsuitable to do so.
It can be done with roundabouts, as with conditionally existing members, for example.
Such definitions (unintentionally) allow some weird usages, e.g.,
some_subrange.operator[]<int[42]>(0)
.
That may not be portable due to [constraints], and perhaps SD-8.
Currently
view_interface::operator[]
overloads are specified as below ([view.interface.general]/1):Making these functions templates is a common implementation technique, but IMO it's a bit weird in the standard. Such definitions (unintentionally) allow some weird usages, e.g.,
some_subrange.operator[]<int[42]>(0)
.I tried to submit an LWG issue for this, but Daniel told me my resolution was wrong as it would cause ODR violation when involving incomplete types.
Formerly proposed resolution (abandoned):
Is it able to make these
operator[]
overloads non-template without ODR violation?