Reputation: 955
I'm not sure what's going on and how to accurately describe it. Here's the source code
template <typename ...Args>
void foo(Args &&...args)
{
bar(std::forward<Args>(args)...);
}
My friend with clang-format 10 on Ubuntu generated this
template <typename ... Args>
void foo(Args &&... args)
{
bar(std::forward<Args>(args)...);
}
But my clang-format 11 on Arch with the same .clang-format
file generated the following:
template <typename ...Args>
void foo(Args &&...args)
// ^^^^ Notice the missing space after ...
{
bar(std::forward<Args>(args)...);
}
I didn't find suspicious changes in clang-fotmat 11's changelog. What am I missing?
Upvotes: 4
Views: 925
Reputation: 5421
Since I had the same issue, after some git bisect
ing, I found the commit that introduced this change: https://reviews.llvm.org/D83564
clang-format does not obey
PointerAlignment: Right
for ellipsis in declarator for pack
The reasoning behind this change is that you can either consider the annotation &&...
part of the type (PointerAlignment: Left
) or of the variable (PointerAlignment: Right
) or if you want, put it in the middle (PointerAlignment: Middle
). This change was meant to prevent an inconsistency between having a &&
and &&...
parameter (pack), which would be formatted like this
template <typename Arg, typename ...Args>
void foo(Arg &&arg, Args &&... args)
{
bar(std::forward<Args>(args)...);
}
with an older clang-format, but like this
template <typename Arg, typename ...Args>
void foo(Arg &&arg, Args &&...args)
{
bar(std::forward<Args>(args)...);
}
with a more recent one.
Upvotes: 3