Skip to content

Ambiguity when calling function with sigc::slot as argument with the result of sigc::mem_fun #79

Open
@H2NCH2COOH

Description

@H2NCH2COOH

When compiling the following piece of code:

#include <sigc++/sigc++.h>

void f(sigc::slot<void()> s) {}
void f(sigc::slot<void(int)> s) {}

class A {
   void test() {
      f(sigc::mem_fun(*this, &A::test));
   }
};

The following error is reported by GCC:

a.cpp: In member function ‘void A::test()’:
a.cpp:8:39: error: call of overloaded ‘f(sigc::bound_mem_functor<void (A::*)()>)’ is ambiguous
    8 |       f(sigc::mem_fun(*this, &A::test));
      |                                       ^
a.cpp:3:6: note: candidate: ‘void f(sigc::slot<void()>)’
    3 | void f(sigc::slot<void()> s) {}
      |      ^
a.cpp:4:6: note: candidate: ‘void f(sigc::slot<void(int)>)’
    4 | void f(sigc::slot<void(int)> s) {}
      | 

Why is this ambiguous?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions