Skip to content

[clang-format] Inconsistent formatting of template parameter with ternary #81385

Closed
@Disservin

Description

@Disservin

The following code gets formatted inconsistently.
➜ ~ cat main.cpp

template <int num> void foo() {}

void bar() { return foo<true ? 1 : 2>(); }

int main() {
  bar();

  foo<true ? 1 : 2>();

  return 0;
}  

➜ ~ clang-format-18 main.cpp

template <int num> void foo() {}

void bar() { return foo < true ? 1 : 2 > (); }

int main() {
  bar();

  foo<true ? 1 : 2>();

  return 0;
} 

The foo function call inside bar() is formatted differently than the one inside the main function.

Mainly weird spaces are added to the template parameter

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions