#include <memory>
class Base{};
class Derived : public Base {};
class ExtraDerived : public Derived {};
bool IsBase(Base*){ return true; }
bool IsBase(Derived*){ return false; }
bool IsBase(std::shared_ptr<Base>){ return true; }
bool IsBase(std::shared_ptr<Derived>){ return false; }
int main()
{
auto derived = std::make_shared<Derived>();
auto extra_derived = std::make_shared<ExtraDerived>();
// works
auto raw_result_derived = IsBase(derived.get());
auto raw_result_extra_derived = IsBase(extra_derived.get());
auto shared_result_derived = IsBase(derived);
// doesn't work
auto shared_result_extra_derived = IsBase(extra_derived);
}
I2luY2x1ZGUgPG1lbW9yeT4KCmNsYXNzIEJhc2V7fTsKY2xhc3MgRGVyaXZlZCA6IHB1YmxpYyBCYXNlIHt9OwpjbGFzcyBFeHRyYURlcml2ZWQgOiBwdWJsaWMgRGVyaXZlZCB7fTsKCgpib29sIElzQmFzZShCYXNlKil7IHJldHVybiB0cnVlOyB9CmJvb2wgSXNCYXNlKERlcml2ZWQqKXsgcmV0dXJuIGZhbHNlOyB9Cgpib29sIElzQmFzZShzdGQ6OnNoYXJlZF9wdHI8QmFzZT4peyByZXR1cm4gdHJ1ZTsgfQpib29sIElzQmFzZShzdGQ6OnNoYXJlZF9wdHI8RGVyaXZlZD4peyByZXR1cm4gZmFsc2U7IH0KCmludCBtYWluKCkgCnsKICAgIGF1dG8gZGVyaXZlZCA9IHN0ZDo6bWFrZV9zaGFyZWQ8RGVyaXZlZD4oKTsKICAgIGF1dG8gZXh0cmFfZGVyaXZlZCA9IHN0ZDo6bWFrZV9zaGFyZWQ8RXh0cmFEZXJpdmVkPigpOwogICAgLy8gd29ya3MKICAgIGF1dG8gcmF3X3Jlc3VsdF9kZXJpdmVkID0gSXNCYXNlKGRlcml2ZWQuZ2V0KCkpOwogICAgYXV0byByYXdfcmVzdWx0X2V4dHJhX2Rlcml2ZWQgPSBJc0Jhc2UoZXh0cmFfZGVyaXZlZC5nZXQoKSk7CiAgICBhdXRvIHNoYXJlZF9yZXN1bHRfZGVyaXZlZCA9IElzQmFzZShkZXJpdmVkKTsKICAgIC8vIGRvZXNuJ3Qgd29yawogICAgYXV0byBzaGFyZWRfcmVzdWx0X2V4dHJhX2Rlcml2ZWQgPSBJc0Jhc2UoZXh0cmFfZGVyaXZlZCk7Cn0=
prog.cpp: In function ‘int main()’:
prog.cpp:23:60: error: call of overloaded ‘IsBase(std::shared_ptr<ExtraDerived>&)’ is ambiguous
prog.cpp:23:60: note: candidates are:
prog.cpp:11:6: note: bool IsBase(std::shared_ptr<Base>)
prog.cpp:12:6: note: bool IsBase(std::shared_ptr<Derived>)
prog.cpp:23:60: error: unable to deduce ‘auto’ from ‘<expression error>’
prog.cpp:19:10: warning: unused variable ‘raw_result_derived’ [-Wunused-variable]
prog.cpp:20:10: warning: unused variable ‘raw_result_extra_derived’ [-Wunused-variable]
prog.cpp:21:10: warning: unused variable ‘shared_result_derived’ [-Wunused-variable]
prog.cpp:23:10: warning: unused variable ‘shared_result_extra_derived’ [-Wunused-variable]