title: Lambda capture list: capturing object's member field by value not possible without capturing the whole object?
body: <p>The following code</p>
  
  <pre><code>void CMainWindow::someMethod(const CLocationsCollection&amp; parentItem)
  {
      auto f = [this, parentItem.displayName](){};
  }
  </code></pre>
  
  <p>gives me an error:</p>
  
  <blockquote>
    <p>error C2143: syntax error : missing ']' before '.'</p>
  </blockquote>
  
  <p>If I wanted to catch <code>parentItem.displayName</code> by ref, I'd make a non-dependent alias identifier for it:</p>
  
  <pre><code>const QString&amp; name = parentItem.displayName;
  auto f = [this, &amp;name](){}; // Or should it be [this, name] ?
  </code></pre>
  
  <p>But I need to capture it by value, and I don't want to capture the whole <code>parentItem</code> because it's heavy. Any solution?</p>
  
  <p>P. S. Names in the capture list must be identifiers. Isn't <code>parentItem.displayName</code> (as a whole) an identifier? Why can't it be parsed properly by the compiler?</p>