title: Template compilation error: 'X' does not refer to a value
body: <p>I am getting the following error: <code>'ComponentManager' does not refer to a value</code> when compiling a subclass which inherits from this parent class:</p>
  
  <pre><code>template&lt;typename ComponentManager&gt;
  class component_collection {
  protected:
    int n_components;
    int n_versions;
    int first_blank;
    int last_used;
    std::vector&lt;std::deque&lt;shared_ptr&lt;entity&lt;ComponentManager&gt;&gt;&gt;&gt; entity_pointers;
  
  public:
    component_collection(int n_c, int n_v) :
      n_components(n_c),
      n_versions(n_v),
      first_blank(0),
      last_used(0),
      entity_pointers(n_v, std::deque&lt;shared_ptr&lt;entity&lt;ComponentManager&gt;&gt;&gt;()) // &lt;-- ERROR HERE
    {}
  
    ...
  
  };
  </code></pre>
  
  <p>I am confused as to how I should initialise the <code>std::vector</code> with <code>n_v</code> empty <code>std::deque</code>s in the constructor.</p>
  
  <p>The sub-class declares a similar <code>vector</code> of <code>deque</code>s and compiles / worked as expected (until I added the <code>vector&lt;deque&gt;</code> to the parent, that is):</p>
  
  <pre><code>template&lt;typename ComponentManager&gt;
  class test_component_collection : public component_collection&lt;ComponentManager&gt; {
    std::vector&lt;std::deque&lt;int&gt;&gt; values;
  
  public:
    test_component_collection(int n_c, int n_v) :
        component_collection&lt;ComponentManager&gt;(n_c, n_v),
        values(n_v, std::deque&lt;int&gt;()) // &lt;-- NO ERROR HERE
    { }
  
    ...
  
  };
  </code></pre>
  
  <p>So it seems this is something to do with this being a container of <code>std::shared_ptr&lt;entity&lt;ComponentManager&gt;&gt;</code>, but I don't see why that would be a problem (the <code>entity</code> header is included, takes a <code>&lt;ComponentManager&gt;</code> as you would expect, and a <code>ComponentManager</code> is provided when all these classes are used).</p>
  
  <p>I am clearly missing something...</p>
  
  <p><strong>Update</strong></p>
  
  <p>Here's the code for <code>entity</code>:</p>
  
  <pre><code>template&lt;typename ComponentManager&gt;
  class entity {
  protected:
    ComponentManager &amp; component_manager;
  
  public:
    entity(ComponentManager &amp; cm) : component_manager(cm) {}
    void initialise_components(shared_ptr&lt;entity&lt;ComponentManager&gt;&gt; sp) {}
  };
  </code></pre>
  
  <p>Adding this at the top of <code>component_collection</code> seems to fix things (the compilation error at least, I've not thoroughly tested the results):</p>
  
  <pre><code>template&lt;typename ComponentManager&gt; using entity_ptr_deque = std::deque&lt;shared_ptr&lt;entity&lt;ComponentManager&gt;&gt;&gt;;
  </code></pre>
  
  <p>And then substituting <code>entity_ptr_deque&lt;ComponentManager</code> in as appropriate. This aids readability, so I might leave it in anyway, but it doesn't help understand the error, especially as a minimal example builds fine (see comments).</p>
  
  <p><strong>Update 2</strong></p>
  
  <p>Using <a href="http://melpon.org/wandbox/" rel="nofollow noreferrer">Wandbox</a> from the comments, I found that my full class didn't compile, while the version edited by @VittorioRomeo did.</p>
  
  <p>Switching from Clang to GCC on Wandbox (I'm using Clang locally) gave a very different error message:</p>
  
  <pre><code>declaration of 'auto component_collection&lt;ComponentManager&gt;::entity(int)' 
  changes meaning of 'entity'
  </code></pre>
  
  <p>This is a method that was present before I added the <code>std::vector&lt;std::deque&lt;shared_ptr&lt;entity&lt;ComponentManager&gt;&gt;&gt;&gt; entity_pointers;</code> and associated constructor update. It of course masks the name <code>entity</code> in the class definition, hence the error. Clang's error message pointed somewhere else entirely.</p>