class Incomplete;
template <typename T>
class Wrap { T x; };
void f(const std::vector<Wrap<Incomplete>*>& data) {
data[0];
}
This compiles today since the pointer returned from data[0] does not require a complete type. However, once non-member operator[] is possible, the compiler has to look into Wrap<Incomplete>, whether it has a hidden friend operator[] which is a better match than the one from std::vector. While instantiating Wrap<Incomplete>, T x leads to an error, making the above example ill-formed.
Similar issues exist and
operator[]
would be no exception:This compiles today since the pointer returned from
data[0]
does not require a complete type. However, once non-memberoperator[]
is possible, the compiler has to look intoWrap<Incomplete>
, whether it has a hidden friendoperator[]
which is a better match than the one fromstd::vector
. While instantiatingWrap<Incomplete>
,T x
leads to an error, making the above example ill-formed.