<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62204>62204</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang format single line function incompatible with template headers breaks
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dutkalex
</td>
</tr>
</table>
<pre>
Hi! I have lots of very small functions of the following form in my codebase:
```cpp
template<typename T>
auto add(T const& lhs, T const& rho){ return lhs + rhs; }
```
I would like to format them in this compact way, but it seems like clang-format does not allow it. With `AlwaysBreakTemplateDeclarations` and `AllowShortFunctionsOnASingleLine` enabled, clang-format produces the following:
```cpp
template<typename T>
auto add(T const& lhs, T const& rho)
{
return lhs + rhs;
}
```
To actually get clang-format to put the body on the same line, I have to disable `AlwaysBreakTemplateDeclarations`, which deteriorates the readability in my opinion:
```cpp
template<typename T> auto add(T const& lhs, T const& rho){ return lhs + rhs; }
```
To the best of my understanding, this problem also shows up for empty classes, and the following formatting is impossible to obtain:
```cpp
template<typename T>
class SomeEmptyClass {};
```
I don't know if this is a bug or just an oversight, but I think the function body and template header policies should not interfere with one another in this way...
Thank you in advance
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VU1v4zYQ_TX0ZRBDoh1_HHSIkzUaoEAPCdDzSBxbXFMcgTOKq39fUHJ2m3QPxQJdwIApfojvvXlvhCL-HIkqc38w908LHLTlVLlBLxjor0XNbqx-88aW8AwtvhEEVgE-wRulEaTDEOA0xEY9x2leW4ITh8BXH89w4tSBj9CN0LCjGoXM6sEUT6Z4MJti_jV9P88odX1AJbN61LGniB3Bq1l9mVdxUAZ0ztjdKzQcRY3dQGjF2Ef4x0xq2di92R4gkQ4p5i1g7AFSK2Z1ALN9-gRgfnyGKw_BQfAXAuUJO2omNFHQ1gs03PXYKFxxzLfWg4JXEKJO5nNNwHi-ux11TAKRFTDrAV6X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