Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mattkretz opened this issue Jun 25, 2021 · 0 comments

Comments

@mattkretz
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant