The code below does not compile in C++:
template <class Result, class... Params>
class Slot
{
public:
virtual Result operator()(Params ... args) = 0;
};
using IntSlot = awl::Slot<void, int>;
class SlotA : public IntSlot {};
class SlotB : public IntSlot {};
class Handler :
public SlotA,
public SlotB
{
public:
void SlotA::operator()(int value) override
{
lastValueA = value;
}
void SlotB::operator()(int value) override
{
lastValueB = value;
}
int lastValueA = 0;
int lastValueB = 0;
};
MSVC error:
error C2535: 'void `anonymous-namespace'::Handler::operator ()(int)': member function already defined or declared
The code below compiles with MSVC:
struct SlotA
{
virtual void func(int value) = 0;
};
struct SlotB
{
virtual void func(int value) = 0;
};
class MultiObserver :
public SlotA,
public SlotB
{
public:
void SlotA::func(int value) override
{
aValue = value;
}
void SlotB::func(int value) override
{
aValue = value;
}
int aValue = 0;
int bValue = 0;
};
void f()
{
MultiObserver mo;
}
but GCC fails to compile this code with the following error:
error: cannot define member function ‘{anonymous}::SlotA::func’ within ‘{anonymous}::MultiObserver’
error: cannot define member function ‘{anonymous}::SlotB::func’ within ‘{anonymous}::MultiObserver’

