<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/101138>101138</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-format: templated operator with std::enable_if_t followed by a comment causes formatting to be different.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
vesterij
</td>
</tr>
</table>
<pre>
This is very specific. You need to have a templated operator function with `std::enable_if_t` followed by a comment.
```cpp
// Correct.
template< typename T >
constexpr std::enable_if_t< std::is_integral_v< T >, bool >
operator|( const T& left, const T& right ) noexcept
{
return left < 3 * right;
}
// Incorrect.
template< typename T >
constexpr std::enable_if_t< std::is_integral_v< T >, bool > // This comment breaks formatting.
operator|( const T& left, const T& right ) noexcept
{
return left < 3 * right;
}
```
This gets formatted into:
```cpp
// Correct.
template< typename T >
constexpr std::enable_if_t< std::is_integral_v< T >, bool >
operator|( const T& left, const T& right ) noexcept
{
return left < 3 * right;
}
// Incorrect.
template< typename T >
constexpr std::enable_if_t< std::is_integral_v< T >, bool > // This comment breaks formatting.
operator|( const T & left, const T & right ) noexcept
{
return left < 3 * right;
}
```
There is an extra space with parameters `const T & left` but this only happens if there is a commet for `std::enable_if_t`
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsVctu4zgQ_Brq0ohBk7EUHXRwnDWw91z2ZJBUS2KWIgWy5cR_v9DDeWCNOQ3mAQxgWADJblYVC10qJdt6xIrtHtnuKVMjdSFWZ0yE0b5kOtSX6rmzCWyCM8YLpAGNbazZwD9hBI9YAwXo1BlBAWE_OEVYQxgwKgoRmtEbssHDq6UOWM4T1UzumdyjV9rhyTYnYjmHJjgXXrEGfQEFJvQ9etow_sT4fv3P-fIzw7CuiCMTRziEGNFcD19BMHkAugzoVY_wDEz-teyb4BPh2xDhJhR5-Fi36WQ9YRuVO52nnaWNOIAOwX20vLJlxYGJB5hvgGcmcnDY0HT-01K0bUfARAk-4JvBgVYyxeOVbRmRxujnapjulcDEfqlk8nqsePqizqLF3978PDVgBTE7Zn1C0BHVvwmaEHtFZH27-SVEu5rps4Yz7hbpHS3WYD2Fif8fI_5ORvwOToQbssGP9CJGnMau8oBvFBWkQRlc5uigouqRMKZppP4PcM5BjwQ0kQ_eXaBTw4A-gW2A3vsuutCkB3xrMmd1JetSlirDalsIIYXkW551lTa5FCUKLMS2xFxpaRpT7Divdw9KaJPZSnBxzwvJecGl5BtT5jtd1ELxRjfbEtk9x15Zt3Hu3G9CbDOb0ojVlm-38iFzSqNLczgJYZzy7d3yeEyIKa5iNdXd6bFN7J47myh9dCJLDqsvVXJ_K6JmRW-Rv51JYNSY8LONpgTUCLVtGoxTamVjdFVHNKSp5-zE1lI36o0JPRPHCeP6uRtieEFDTBxn6omJ48r-XIn_AgAA__-BjVgw">