<div dir="ltr"><div>I've been using clang-format for quite some time and it's a great tool. However, it has undesirable behavior in the situations listed below (or maybe I couldn't find a way to configure it properly):</div><div><br></div><div>1. AlwaysBreakTemplateDeclarations documentation states "If true, always break after the template<...> of a template declaration."</div><div><br></div><div>So, I expect to see, for example, the following result:</div><div><br></div><div><font face="monospace, monospace">template <class T></font></div><div><font face="monospace, monospace">inline constexpr T sqr(const T& x) { return x * x; }</font></div><div><br></div><div>However, clang-format produces this even with AllowShortFunctionsOnASingleLine and AllowShortBlocksOnASingleLine set to true:</div><div><br></div><div><font face="monospace, monospace">template <class T></font></div><div><font face="monospace, monospace">inline constexpr T sqr(const T& x) {</font></div><div><font face="monospace, monospace">    return x * x;</font></div><div><font face="monospace, monospace">}</font></div><div><br></div><div>2. All spaces are removed in operator declarations, so instead of</div><div><br></div><div><font face="monospace, monospace">point operator + (point lhs, point rhs);<br></font></div><div><br></div><div>I get</div><div><br></div><div><font face="monospace, monospace">point operator+(point lhs, point rhs);<br></font></div><div><br></div><div>3. AllowAllParametersOfDeclarationOnNextLine is great, but it doesn't work with template parameters, so I can't write, for example</div><div><br></div><div><div><font face="monospace, monospace">template <</font></div><div><font face="monospace, monospace">    class Derived,</font></div><div><font face="monospace, monospace">    class Iterator,</font></div><div><font face="monospace, monospace">    class Category  = use_default,</font></div><div><font face="monospace, monospace">    class Value     = use_default,</font></div><div><font face="monospace, monospace">    class Reference = use_default,</font></div><div><font face="monospace, monospace">    class Pointer   = use_default,</font></div><div><font face="monospace, monospace">    class Distance  = use_default></font></div><div><font face="monospace, monospace">class iterator_adaptor;</font></div></div><div><br></div><div>4. There's no support for initialization list syntax with a comma on the left:</div><div><br></div><div><font face="monospace, monospace">point::point(int x, int y)</font></div><div><font face="monospace, monospace">    : x(x)</font></div><div><font face="monospace, monospace">    , y(y)</font></div><div><font face="monospace, monospace">{}</font></div><div><br></div><div>5. There's no support for the following (more readable to me) lambda formatting:</div><div><br></div><div><pre class="gmail-de1" style="padding:0px;border:0px none white;background-image:none;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;line-height:1.2em;border-radius:5px;margin-top:0px;margin-bottom:0px;width:55em;overflow:auto;font-stretch:normal;vertical-align:top">std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) {</pre><pre class="gmail-de1" style="padding:0px;border:0px none white;background-image:none;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;line-height:1.2em;border-radius:5px;margin-top:0px;margin-bottom:0px;width:55em;overflow:auto;font-stretch:normal;vertical-align:top">    return std::toupper(c); </pre><pre class="gmail-de1" style="padding:0px;border:0px none white;background-image:none;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;line-height:1.2em;border-radius:5px;margin-top:0px;margin-bottom:0px;width:55em;overflow:auto;font-stretch:normal;vertical-align:top">});</pre></div><div><br></div><div>6. Semicolon from the empty statement is carried to the next line:</div><div><br></div><div><div><font face="monospace, monospace">for (int i = 0; i < n; ++i)</font></div><div><font face="monospace, monospace">    ;</font></div></div><div><br></div><div>7. When FixNamespaceComments is set to false, the empty line before the namespace closing bracket is removed.</div><div><br></div><div>8. +1 to the issue with breaking before the operator -> raised before.</div><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Best regards,<br>Oleksandr</div></div></div></div></div></div></div>
</div>