title: Overload resolution for inherited functions
body: <p>I want to have a struct that takes an arbitrary number of lambdas and serve as a central calling point for all their call operators.</p>
  
  <p>If the call operator is invoked with an argument list that doesn't match any of the lambdas given on construction, a default call operator should be called.</p>
  
  <p>I thought the following code would accomplish exactly this. The call operator for every lambda is "lifted" into the <code>Poc</code> class via <code>using</code>.</p>
  
  <pre><code>template &lt;typename ...Lambdas&gt;
  struct Poc : Lambdas...
  {
      using Lambdas::operator() ...; // Lift the lambda operators into the class
  
      template &lt;typename ...Ts&gt;
      auto operator() (Ts...)
      {
          std::cout &lt;&lt; "general call" &lt;&lt; std::endl;
      }
  };
  
  // Deduction guide
  template &lt;typename ...Ts&gt;
  Poc(Ts... ts)-&gt;Poc&lt;Ts...&gt;;
  
  int main()
  {
      auto l_int = [](int) {std::cout &lt;&lt; "int" &lt;&lt; std::endl; };
  
      Poc poc{l_int};
      poc(1);//calls the default operator. why?
  
      return 0;
  }
  </code></pre>
  
  <p>When I don't have the default call operator in the struct, everything works as expected (with valid argument lists). If I add it to the struct (as in the code above), the default operator gets called everytime, no matter which arguments I call it with.</p>
  
  <p>In my understanding, the lambda-call-operators and the structs (default) call-operator are present in the same scope. Therefore, they should all be looked at for the overload resolution. Since the lamdba-operator is more specific than the generic default operator, it should be chosen.</p>
  
  <p>Apparently that is not the case. Why is that?</p>
  
  <p>I tested on <a href="https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B" rel="noreferrer">Microsoft Visual C++</a>, <a href="http://en.wikipedia.org/wiki/Clang" rel="noreferrer">Clang</a> and <a href="http://en.wikipedia.org/wiki/GNU_Compiler_Collection" rel="noreferrer">GCC</a> (all in their latest versions).</p>
  
  <p>Edit:</p>
  
  <ul>
  <li>MSVC 15.8.9</li>
  <li>GCC 9.0.0 (via <a href="https://wandbox.org/" rel="noreferrer">Wandbox</a>)</li>
  <li>Clang 8.0.0 (via <a href="https://wandbox.org/" rel="noreferrer">Wandbox</a>)</li>
  </ul>