title: Why MSVC still compiles to error for calling a method after removing const-ness of the object?
body: <p>To avoid complexity, below is a minimal example. For some reason, I have to pass normal object as <code>const</code> to some method and use it as such:</p>
  <pre><code>#include&lt;iostream&gt;
  #define CALL(OBJECT, METHOD) \
      const_cast&lt;std::remove_const_t&lt;std::remove_reference_t&lt;decltype(OBJECT)&gt;&gt;&amp;&gt;(OBJECT).METHOD()
  
  struct X { void foo () { std::cout &lt;&lt; &quot;X::foo()\n&quot;; } };
  int main ()
  {
    const X x;
    CALL(x,foo);
  }
  </code></pre>
  <p>Above code compiles fine for g++ &amp; clang++. However with <a href="https://godbolt.org/" rel="nofollow noreferrer">MSVC compiler</a> it results in below error:</p>
  <blockquote>
  <p>Left of <code>.foo()</code> must have a <code>class/struct/union</code></p>
  </blockquote>
  <p>Is this a compiler bug? What can be a workaround fix within that macro?</p>