1.
function overload resolution is completed inside a struct/class scope, also before virtual function dispatch.
Code below member ‘fun’ is ambiguous
2.
function overload resolution happens in sequence, which can't goes back.
Like SFINAE
--
If the resulting set of declarations are
1. not all from sub-objects of the same type,
2. or the set has a non-static member and includes members from distinct sub-objects,
there is an ambiguity and the program is ill-formed.
Otherwise that set is the result of the lookup.
Reference:
Name resolution and overloading
Function with parameter type that has a copy-constructor with non-const ref chosen?
function overload resolution is completed inside a struct/class scope, also before virtual function dispatch.
Code below member ‘fun’ is ambiguous
struct Dummy{};
struct Base1
{
virtual void fun(int)
{
}
};
struct Base2
{
virtual void fun(Dummy){}
};
struct De : Base1, Base2
{
};
int main()
{
De d;
d.fun(Dummy());
}
2.
function overload resolution happens in sequence, which can't goes back.
Like SFINAE
--
If the resulting set of declarations are
1. not all from sub-objects of the same type,
2. or the set has a non-static member and includes members from distinct sub-objects,
there is an ambiguity and the program is ill-formed.
Otherwise that set is the result of the lookup.
Reference:
Name resolution and overloading
Function with parameter type that has a copy-constructor with non-const ref chosen?
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.