Skip to content

non-member operator[]: Explore consequences from ADL and indirectly incomplete types #81

@mattkretz

Description

@mattkretz

Similar issues exist and operator[] would be no exception:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions