title: std::dynamic_pointer_cast isn't casting correctly downwards
body: <p>I'm having an issue that I'll explain after I post the code:</p>
  
  <pre><code>template &lt;class T&gt; 
  std::shared_ptr&lt;T&gt;
  getWidget(const std::string&amp; id) {
    auto iter = findObject(id);
  
    if (iter != m_widgets.end()) return std::dynamic_pointer_cast&lt;T&gt;(*iter);
  
    return nullptr;
  }
  
  const Widget::Ptr
  getType(const std::string&amp; id) {
    auto iter = findObject(id);
  
    if (iter != m_widgets.end()) {
      if ((*iter)-&gt;getWidgetType() == "Label")
        return std::dynamic_pointer_cast&lt;Label&gt;(*iter);
      else if ((*iter)-&gt;getWidgetType() == "Editbox")
        return std::dynamic_pointer_cast&lt;EditBox&gt;(*iter);
      else if ((*iter)-&gt;getWidgetType() == "ButtonLabel")
        return std::dynamic_pointer_cast&lt;ButtonLabel&gt;(*iter);
      else if ((*iter)-&gt;getWidgetType() == "Menu")
        return std::dynamic_pointer_cast&lt;Menu&gt;(*iter);
    }
  }
  
  auto type = SceneManager::getCurrentScene().m_gui.getType(widgetId);
  
  SceneManager::getCurrentScene().m_gui.getWidget&lt;decltype(type)&gt;(widgetId)-&gt;attachToMenu(getId());
  </code></pre>
  
  <p><code>Widget::Ptr</code> is just a <code>typedef std::shared_ptr&lt;Widget&gt;</code>. As you can see, <code>m_widgets</code> is a list filled with Widgets which are a base class that <code>Label</code>, <code>EditBox</code>, <code>ButtonLabel</code>, and Menu are derived from. I'm trying to cast downwards to those classes so I can get the type, and use my <code>getWidget()</code> to edit the derived object. I'm getting this error however:</p>
  
  <blockquote>
    <p>error: 'class std::shared_ptr' has no member named 'attachToMenu'|</p>
  </blockquote>
  
  <p>This means obviously that it's not casting correctly and it's returning a Widget. Any help would be great, thanks!</p>