The following test case shows that we get an incorrect line break when --break-return-type is set.
This is with AStyle 3.1
Test case
class Foo
{
public:
template <typename ReturnType>
ReturnType
bar(const ReturnType& x) const;
};
template <>
int
Foo::bar<int>(const int& x) const;
template <typename ReturnValue>
ReturnValue
Foo::bar(const ReturnValue& x) const
{
return x;
}
template <>
int
Foo::bar<int>(const int& x) const
{
return x;
}
This ends up as:
class Foo
{
public:
template <typename ReturnType>
ReturnType
bar(const ReturnType& x) const;
};
template <>
int
Foo::bar<int>(const int& x) const;
template <typename ReturnValue>
ReturnValue
Foo::bar(const ReturnValue& x) const
{
return x;
}
template <>
int
Foo::bar<int>
(const int& x) const
{
return x;
}
As we see, the last function gets an unwanted newline before the parameter list. I.e. it should have been
template <>
int
Foo::bar<int>(const int& x) const
{
return x;
}
not
template <>
int
Foo::bar<int>
(const int& x) const
{
return x;
}
It can be reproduced with:
./astyle --options=none --break-return-type < test.cpp > test.cpp.new && diff test.cpp test.cpp.new
23c23,24
< Foo::bar<int>(const int& x) const
---
> Foo::bar<int>
> (const int& x) const
./astyle -V
Artistic Style Version 3.1