C++ Logo


Advanced search

Subject: [std-proposals] Ambiguous function overload resolution for multiple inheritance
From: Peter Neiß (me_at_[hidden])
Date: 2019-09-23 12:16:43

Hello to all,

i am new to this list, so if i am doing anything wrong please tell me so.

I like to propose the following to make overload resolution more precise.
The following code shows my problem: (testet with gcc, clang, msvc)

struct P {};
struct Q {};

struct A { void f(P){} };
struct B { void f(Q){} };

struct AB: A, B
// using A::f;
// using B::f;

void main() {
        P p;
        AB ab;
        ab.f(p); // is ambiguous

For me, it is counter intuitive that the overload resolution mechanism
today is not able to disambiguate the call ab.f(p). So if the candidate
set is composed only of inherited functions, the first implicit parameter
should not be included in the overload resolution.

This has use cases for the observer pattern with exact subject Type.

Thank you,

Peter Neiss

STD-PROPOSALS list run by herb.sutter at gmail.com

Standard Proposals Archives on Google Groups