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

overload: ambiguous for compatible types #16

Open
pitti98 opened this issue Apr 27, 2017 · 2 comments
Open

overload: ambiguous for compatible types #16

pitti98 opened this issue Apr 27, 2017 · 2 comments

Comments

@pitti98
Copy link

pitti98 commented Apr 27, 2017

If you use final function objects to overload on types that are implicitly convertible to each other the overload becomes ambiguous.

Example:

struct X;
struct Y {
//	Y(const X&){} // enable this to fail
};
struct X {
//	operator Y() const { return Y(); }  // or enable this to fail
};

struct Foo final { void operator()(X) const { printf("X\n"); } };
struct Bar final { void operator()(Y) const { printf("Y\n"); } };
int main()
{
	auto ol = std::experimental::overload(Foo(), Bar());
	ol(X());
	return 0;
}

This ticket was opened as requested on https://github.com/viboes/tags/issues/7.

@viboes
Copy link
Owner

viboes commented Apr 27, 2017

As discussed on the linked issue, I don't know how to fix it with the C++17. We will need something else in the language to fix it.

We could as well either forbid the overload of final function objects, to avoid surprises.
We will see what the committee think of this.

Thanks for catching this issue.
BTW, I will need your name if you agree I use it on any associated paper.

@pitti98
Copy link
Author

pitti98 commented Apr 27, 2017

BTW, I will need your name if you agree I use it on any associated paper.

Uhh, sure, go ahead.

We will see what the committee think of this.

Interesting to see, indeed.

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

No branches or pull requests

2 participants