title: Why Argument Dependent Lookup doesn't work with function template dynamic_pointer_cast
body: <p>Consider the following C++ program:</p>
  
  <pre><code>#include &lt;memory&gt;
  
  struct A {};
  
  struct B : A {};
  
  int main()
  {
      auto x = std::make_shared&lt;A&gt;();
      if (auto p = dynamic_pointer_cast&lt;B&gt;(x));
  }
  </code></pre>
  
  <p>When compiling with MSVC 2010, I obtain the following error:</p>
  
  <pre><code>error C2065: 'dynamic_pointer_cast' : undeclared identifier
  </code></pre>
  
  <p>The error persists if <code>auto</code> is replaced by <code>std::shared_ptr&lt;A&gt;</code>. When I fully qualify the call with <code>std::dynamic_pointer_cast</code>, the program successfully compiles.</p>
  
  <p>Also, <a href="http://ideone.com/Z28dC">gcc 4.5.1</a> doesn't like it either:</p>
  
  <pre><code>error: 'dynamic_pointer_cast' was not declared in this scope
  </code></pre>
  
  <p>I thought that <code>std::dynamic_pointer_cast</code> would have been picked by <a href="http://en.wikipedia.org/wiki/Argument-dependent_name_lookup">Koenig lookup</a>, since the type of <code>x</code> lives in the <code>std</code> namespace. What am I missing here ?</p>