title: Is it possible to automatically deduce the type of the pointer to member overloaded function in ternary when called after?
body: <p>So I had this scenario where I want to call either function of a class, where the function in question has the same prototype but it's also overloaded. Since I know of pointer to members my immediate reaction was something like this:</p>
  <pre><code>struct test
  {
      int overloaded(char) {}
      int overloaded(int) {}
      int overloadedone(char) {}
      int overloadedone(int) {}
  } test;
  
  int main()
  {
      (test.*(true ? (&amp;test::overloaded) : (&amp;test::overloadedone)))(1);
  }
  </code></pre>
  <p>However it turned out the compiler (MSVC - 2019 Preview latest version with std C++ preview) can't deduce the type and I have to write:</p>
  <pre><code>(test.*(true ? static_cast&lt;int (test::*)(int)&gt;(&amp;test::overloaded) : static_cast&lt;int (test::*)(int)&gt;(&amp;test::overloadedone)))(1);
  </code></pre>
  <p>instead which made me return to the good old:</p>
  <pre><code>true ? test.overloaded(1) : test.overloadedone(1);
  </code></pre>
  <p>But I wonder if this is the defined behavior of requiring those cast. Even:</p>
  <pre><code>(test.*static_cast&lt;int (test::*)(int)&gt;(true ? (&amp;test::overloaded) : (&amp;test::overloadedone)))(1);
  </code></pre>
  <p>Doesn't work.</p>
  <p>You have to write said cast on each of the two possibilities for the ternary as in the second example.</p>