title: Why and how do extra parentheses change the type of an expression in C++ (C++11)?
body: <p>Under what circumstances do extra grouping parentheses break things in C++ (C++11 specifically)?  For reasons that are not relevant here, I ended up at one point with an expression that had an extra, unnecessary set of parens around it, and I discovered that the C++11 typeinfo function <code>is_same</code> was determining it to be a different type than the same code without the parentheses.  Here is a boiled-down example of the somewhat baffling behaviour:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main()
  {
    string s = "foo";
    cout &lt;&lt; std::is_same&lt;decltype(s), decltype(string("foo"))&gt;::value;
    cout &lt;&lt; std::is_same&lt;decltype(s), decltype((s))&gt;::value;
    cout &lt;&lt; std::is_same&lt;decltype((s)), decltype(string("foo"))&gt;::value;
    cout &lt;&lt; std::is_same&lt;decltype((s)+"x"), decltype(string("foo")+"x")&gt;::value;
  
    return 0;
  }
  </code></pre>
  
  <p>This code prints "1001", which seems to indicate that the extra parens in the middle two lines cause the expression to be of a different type, but using that parenthesised expression in a larger expression makes it once again the same type.  On the other hand, if I use typeid to get a name for the type, <code>typeid(s)</code> and <code>typeid((s))</code> seem to produce the same thing.</p>
  
  <p>I've now worked around the immediate problem, but I still don't understand why this happens in the first place; searching around for "double parentheses c++" and the like doesn't seem to turn up anything relevant (mostly pages about operator overloading, and compiler extensions that only activate after a specific keyword).</p>
  
  <p>So: what the heck is going on here?  Why is the type of <code>s</code> different from the type of <code>(s)</code>?</p>