title: GCC doesn't see implementation through multiple inheritance
body: <p>I'm trying to generalize my class using policy-based design, and it seems that gcc doesn't see the implementation of pure virtual functions that are implemented in base classes. Here is an example:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  template &lt;typename ReturnValue, template &lt;typename&gt; class... AccessPolicies&gt;
  struct testInterface : public AccessPolicies&lt; ReturnValue &gt;::interface...
  {
  
  };
  
  template &lt;typename DataClass, typename ReturnValue, template &lt;typename&gt; class... AccessPolicies&gt;
  struct testImplementation :   public DataClass,
                                public testInterface&lt; ReturnValue, AccessPolicies... &gt;,
                                public AccessPolicies&lt; ReturnValue &gt;::template implementation&lt; DataClass &gt;...
  {
  
  };
  
  template &lt; typename ReturnValue &gt;
  struct GetByIndex;
  
  template &lt;&gt;
  struct GetByIndex&lt; std::string &gt;
  {
      class interface
      {
      public:
          virtual std::string operator[](size_t ) = 0;
      protected:
          virtual ~interface() = default;
      };
  
      template &lt;class DataClass&gt;
      class implementation
      {
      public:
          virtual std::string operator[](size_t )
          {
              return "test by index";
          }
      protected:
          virtual ~implementation() = default;
      };
  };
  
  template &lt; typename ReturnValue &gt;
  struct GetByName;
  
  template &lt;&gt;
  struct GetByName&lt; std::string &gt;
  {
      class interface
      {
      public:
          virtual std::string operator[](std::string ) = 0;
      protected:
          virtual ~interface() = default;
      };
  
      template &lt;class DataClass&gt;
      class implementation
      {
      public:
          virtual std::string operator[](std::string )
          {
              return "test by string";
          }
      protected:
          virtual ~implementation() = default;
      };
  };
  
  struct data
  {
  
  };
  
  int main()
  {
      testImplementation&lt; data, std::string, GetByIndex, GetByName&gt; test;
      testInterface&lt; std::string, GetByIndex, GetByName &gt;&amp; Test = test;
  
      std::cout &lt;&lt; Test[5] &lt;&lt; std::endl;
  
      return 0;
  }
  </code></pre>
  
  <p>Errors I'm getting are:</p>
  
  <pre><code>..\nienazwany\main.cpp: In function 'int main()':
  ..\nienazwany\main.cpp:78:67: error: cannot declare variable 'test' to be of abstract type 'testImplementation&lt;data, std::basic_string&lt;char&gt;, GetByIndex, GetByName&gt;'
       testImplementation&lt; data, std::string, GetByIndex, GetByName&gt; test;
                                                                     ^
  ..\nienazwany\main.cpp:10:8: note:   because the following virtual functions are pure within 'testImplementation&lt;data, std::basic_string&lt;char&gt;, GetByIndex, GetByName&gt;':
   struct testImplementation :   public DataClass,
          ^
  ..\nienazwany\main.cpp:53:29: note:     virtual std::string GetByName&lt;std::basic_string&lt;char&gt; &gt;::interface::operator[](std::string)
           virtual std::string operator[](std::string ) = 0;
                               ^
  ..\nienazwany\main.cpp:26:29: note:     virtual std::string GetByIndex&lt;std::basic_string&lt;char&gt; &gt;::interface::operator[](size_t)
           virtual std::string operator[](size_t ) = 0;
                               ^
  ..\nienazwany\main.cpp:81:24: error: request for member 'operator[]' is ambiguous
       std::cout &lt;&lt; Test[5] &lt;&lt; std::endl;
                          ^
  ..\nienazwany\main.cpp:53:29: note: candidates are: virtual std::string GetByName&lt;std::basic_string&lt;char&gt; &gt;::interface::operator[](std::string)
           virtual std::string operator[](std::string ) = 0;
                               ^
  ..\nienazwany\main.cpp:26:29: note:                 virtual std::string GetByIndex&lt;std::basic_string&lt;char&gt; &gt;::interface::operator[](size_t)
           virtual std::string operator[](size_t ) = 0;
  </code></pre>
  
  <p>There are two problem's I don't quite get:</p>
  
  <ol>
  <li>The compiler seems to not consider <code>AccessPolicy&lt; ReturnType &gt;::implementation&lt; DataClass &gt;...</code> to be an implementation of  <code>AccessPolicy&lt; ReturnType &gt;::interface...</code> even  though the function signatures are exactly the same.</li>
  <li>The compiler cannot resolve which operator[] I'm calling even though they all have different arguments an I'm clearly calling the size_t one (numbers cannot be implicitly converted to strings).</li>
  </ol>
  
  <p><strong>Any ideas why is this happening?</strong></p>
  
  <p>My guess is that even though I'm inheriting directly from "interface" and "implementation" the member functions somehow end up in different namespaces. If that's correct, how do I get around this? </p>
  
  <hr>
  
  <p><strong>EDIT :</strong> added the above example stripped of the templates, as per request</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class GetByIndexInterface
  {
  public:
      virtual std::string operator[](size_t ) = 0;
  protected:
      virtual ~GetByIndexInterface() = default;
  };
  
  class GetByIndexImplementation
  {
  public:
      virtual std::string operator[](size_t )
      {
          return "test by index";
      }
  protected:
      virtual ~GetByIndexImplementation() = default;
  };
  
  
  class GetByNameInterface
  {
  public:
      virtual std::string operator[](std::string ) = 0;
  protected:
      virtual ~GetByNameInterface() = default;
  };
  
  class GetByNameImplementation
  {
  public:
      virtual std::string operator[](std::string )
      {
          return "test by string";
      }
  protected:
      virtual ~GetByNameImplementation() = default;
  };
  
  struct data
  {
  
  };
  
  struct testInterface : public GetByIndexInterface,
                         public GetByNameInterface
  {
  
  };
  
  struct testImplementation :   public data,
                                public testInterface,
                                public GetByIndexImplementation,
                                public GetByNameImplementation
  {
  
  };
  
  int main()
  {
      testImplementation test;
      testInterface&amp; Test = test;
  
      std::cout &lt;&lt; Test[5] &lt;&lt; std::endl;
  
      return 0;
  }
  </code></pre>