I have legacy code:
struct Iface1 { virtual ~Iface1() {} virtual void foo(const int arg1) const = 0; }; struct Iface2 { virtual ~Iface2() {} virtual void foo(const int arg1, const int arg2) const = 0; };
I need to create a decorator for a composite interface. The following code has not even been compiled since it is "ambiguous" for g ++ and MSVC to deduce what type of foo () is being called. Can someone tell me how to make the code below, compile and work? (unfortunately, I do not have time to refactor).
And I donβt even understand why the compiler cannot deduce which function to call, since all function signatures are explicit. Thanks.
struct IfaceDecorator : Iface12 { IfaceDecorator(Iface12& iface) : impl(iface) {} virtual void foo(const int arg1) const { impl.foo(arg1); } virtual void foo(const int arg1, const int arg2) const { impl.foo(arg1, arg2); } private: Iface12& impl; };
barankin
source share