Consider the following C++ program:
#include <memory>
struct A {};
struct B : A {};
int main()
{
auto x = std::make_shared<A>();
if (auto p = dynamic_pointer_cast<B>(x));
}
When compiling with MSVC 2010, I obtain the following error:
error C2065: 'dynamic_pointer_cast' : undeclared identifier
The error persists if auto
is replaced by std::shared_ptr<A>
. When I fully qualify the call with std::dynamic_pointer_cast
, the program successfully compiles.
Also, gcc 4.5.1 doesn't like it either:
error: 'dynamic_pointer_cast' was not declared in this scope
I thought that std::dynamic_pointer_cast
would have been picked by Koenig lookup, since the type of x
lives in the std
namespace. What am I missing here ?