clang-format: Setting to control C++ attributes

This is not a “solution”, but a general workaround for preventing clang-format (and other formatters) from removing line breaks.

Just add an empty line comment at the end of a line like so:

template <typename TChar>
[[gnu::always_inline]] //
static ptr<TChar>
within_limit(ptr<TChar> first, ptr<TChar> last);

template <typename TChar, typename FApply, typename... FApplyRest>
[[gnu::always_inline]] //
static ptr<TChar>
overflow(ptr<TChar> first, ptr<TChar> last, const FApply& apply, const FApplyRest&... apply_rest);

It can’t merge the lines now, as this would comment out the entire rest of the line.

For this specific example, it’s unfortunately not perfect, as it also seems to introduce a second line break after the return type (which looks arguably worse than having everything on a single line). Nontheless I thought this might come in handy in some scenarios (although I haven’t personally used it all that much either).

It’s at least a lot less verbose than turning off clang-format completely for just a single line.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)