<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/81309>81309</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang-format] Inconsistent formatting with template methods and non-template methods
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-format
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          danakj
      </td>
    </tr>
</table>

<pre>
    ```cpp
 // Clang format refuses to let `.copy_from()` share space on the first line.
  header.subspan(kHeaderCupsHwResolutionVertical, 4u)
 .copy_from(base::numerics::U32ToBigEndian(pwg_header_info.dpi.height()));

 // Clang format allows `.copy_from()` share space on the first line.
 header.subspan<kHeaderCupsHwResolutionVertical, 4u>().copy_from(
 base::numerics::U32ToBigEndian(pwg_header_info.dpi.height()));
```

When chaining methods, if a method is a template, it changes what rules clang-format uses for wrapping. In the non-template case, it doesn't let the chained method stay on the same line, even if it would make better wrapping later. In the template case it's more flexible and (better IMO) as it lets the chaining continue on the same line.

For example:
```cpp
 header.subspan(kHeaderCupsBytesPerLine, 4u)
 .copy_from(base::numerics::U32ToBigEndian(
          (bits_per_pixel * image.size().width() + 7) / 8));

  // This is easier to read, arguably.
  header.subspan<kHeaderCupsBytesPerLine, 4u>().copy_from(
 base::numerics::U32ToBigEndian(
          (bits_per_pixel * image.size().width() + 7) / 8));
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VVFvo0YQ_jXrl1EQLHaABx7i5KyL1KpVdW0frQUG2Muyi3aGc9xfXy3gOm6vp0rXWEgG45nvm2_mm1VEurOIpdjtxe5poybunS8bZdXL503lmnMp7uPlqsdRxE8ifgAhD0Ie4NEo20Hr_KAYPLYTIQE7MMgg7uOoduP52Ho3CJkLWYj7GKhXHoFGVSM4C9wjtNoTg9EWozU99Kga9BFNFY3KCpm_fJx_eZxG-nj6BcmZibWzv6FnXSsj5CNspwCxJLhBrhShSB9E-mCnAb2uaXn6NZWf3F53H2yjZ5Dx1B0X5KO2rYuaUUc96q7nlf9ypfsF5RtaKGPcib5Lg79JkD7-NwnSDwvOLe6S8t2EuAzIW11-79FC3Sttte1gQO5dQ4GkbkGtz6AJFDAOo1GM80sOMbZDglMfhmoySFAHbe9Wbecha52Hk1fjqG0XwfMionX27pIM6lDskrFxSFbIjOfBDP-ceWFzoUGszpdOkBpwbkQIxi9oA2HNcHKTaWBQLwgVMuMVHwKe_4vFDQPQLGRGMDiP0Bp81ZVBULaBMJhLnucffxKyAEUBxiDTlWLIXjvL2k74D4LRW7kPzgO-qmE0c4tv-3I17reMtT8z0s_of1iL_35DXex8-YRYzXQc0R9H_YoGhHwAPagOI9J_4Dq6J91wv9yDkHvIlpsD5F934MWCn3pNYaRQkUYfFpFH1YRSlO8mVZnzvy2YG3d9RYf_xVXvrsal3ZumTJsiLdQGyySLs12cFUm-6UuUiUzquo3jpkqyJEmVjOs0zzJZJXmexRtdylhuYxkXSbHdJTIqijTfbdu6amol1TYR2xgHpU1kzJchcr7baKIJyzxJ42JjVIWG5qNEyremFVKGw8WXIeyumjoS29hoYromYs1mPoZuAndP8GxrZ0kTo-V1wXIwxklzf3XbumFmb90sgvXFZvKm7JnHuT3zwHSa-6mK6tDNQ-Cxft2N3n3GmoU8zNWRkIe5wD8DAAD__2yFQtc">