Skip to content

[clang-format]: Feature Request add option to ReferenceAlignment when using east-const #139717

@LucHermitte

Description

@LucHermitte

It would be nice to have a way to have an extra option to ReferenceAlignment (and PointerAlignment I guess) when QualifierAlignment is set to Right in order to remove any space between const and &, and still add spaces before & the rest of the time.

AFAIK, it is currently (*) impossible to format in the following way:

SomeType & lvref;       // space before "&"
SomeType && rvref;      // space before "&&"
SomeType const& cref;   // no-space before "&", but before "const&"
SomeType const&& crvref // same thing

Indeed, if we select Middle for ReferenceAlignment, an extra space will be added to const &

(*) tested with clang-format 19, and the documentation of clang-format-21 shows no difference on the topic.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions