I’d like to format a set of C++ files so that each function or function template is defined entirely on one line. With input such as:
template <typename T>
void foo(int i)
{
return;
}
template <int I, typename T>
struct Bar {
Bar()
{
}
static int testsmf(double d)
{
return 42;
}
template <typename U>
inline void testmft() const {
int i;
double longname1;
double longname2;
double longname3;
double longname4;
double longname5;
}
};
int main()
{
return 0;
}
I might look for output approximately so:
template <typename T>void foo(int i){ return;}
template <int I, typename T>
struct Bar {
Bar() { }
static int testsmf(double d) { return 42; }
template <typename U> inline void testmft() const { int i; double longname1; double longname2; double longname3; double longname4; double longname5; }
};
int main(){ return 0;}
Currently my clang-format style file (named cf
) is minimal:
ColumnLimit: 0
AllowShortFunctionsOnASingleLine: All
I test via clang-format -style=file:./cf test.cpp
, but alas the only noticeable change in the output is that each function’s opening brace is placed on the same line as its name. I earlier tried starting with the output of clang-format -style=llvm -dump-config
, and changing the two style options as above, but this also didn’t work. Setting ColumnLimit
to a large value such as 1000 makes no difference either. I am using ClangFormat version 18.1.3.