18

Is there a flag in clang-format to change 'const west' to 'east const', so that the following:

void fun(const std::string &s);

would be reformatted to:

void fun(std::string const &s);
4
  • 2
    You can go through the documentation and look for it. It's not too big of a list.
    – Justin
    Sep 12, 2018 at 17:42
  • 2
    I don't think this is something clang format will ever handle. I think clang format works solely with the spaces between tokens, not with the ordering of tokens. This seems more suited for clang tidy. At any rate neither supports it at this time. Perhaps you could submit a feature request for it, or even a patch after discussing with them
    – Justin
    Sep 12, 2018 at 17:59
  • 3
    <joke mode on> Don't join the dark side (east const)!!! :-)
    – roalz
    Sep 13, 2018 at 7:44
  • To arms! They're storming through the gates!
    – Nikos C.
    Apr 1, 2019 at 18:21

2 Answers 2

15

As of Clang-Format 14, there is QualifierAlignment. Add the following line to your .clang-format configuration file:

QualifierAlignment: Right
7

AFAIK it isn't implemented yet, but there is a feature request in their bugtracker.

1

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.