title: why is the overload resolution wrong here?
body: <p>suppose we have this as our setup:</p>
  <pre><code>#include &lt;iostream&gt;
  
  class Base {
  private:
      int a;
  public:
      Base(int a)
          : a(a) {
      }
  
      virtual void print() = 0;
  };
  
  class Child : public Base {
  public:
  
      using Base::Base;
  
      void print() override {
          //some code
      }
  };
  
  class Wrapper {
  private:
      void* base_ptr = nullptr;
  public:
      Wrapper(void* base_ptr)
          : base_ptr(base_ptr) {
          std::cout &lt;&lt; &quot;void* version called\n&quot;;
      }
  
      Wrapper(Base* const&amp; base_ptr)
          : base_ptr(base_ptr) {
          std::cout &lt;&lt; &quot;Base*const&amp; version called\n&quot;;
      }
  
  };
  </code></pre>
  <p>if we do the following:</p>
  <pre><code>Child* child_ptr = new Child(1);
  Wrapper w(child_ptr);
  </code></pre>
  <p>output is:</p>
  <pre><code>Base*const&amp; version called
  </code></pre>
  <p>which is expected and completely normal.
  but if we change <code>Wrapper(Base *const&amp;)</code> to <code>Wrapper(Base*&amp;)</code> we call the <code>void*</code> version:</p>
  <pre><code>class Wrapper {
  private:
      void* base_ptr = nullptr;
  public:
      Wrapper(void* base_ptr)
          : base_ptr(base_ptr) {
          std::cout &lt;&lt; &quot;void* version called\n&quot;;
      }
  
      Wrapper(Base*&amp; base_ptr)
          : base_ptr(base_ptr) {
          std::cout &lt;&lt; &quot;Base*const&amp; version called\n&quot;;
      }
  
  };
  
  int main() {
      Child* child_ptr = new Child(1);
      Wrapper w(child_ptr);
      return 0;
  }
  </code></pre>
  <p>for this version we get this output:</p>
  <pre><code>void* version called
  </code></pre>
  <p>but why is that? shouldn't <code>Base*const&amp;</code> just make it also compatible with temporary objects?</p>