[cfe-users] Clang-Format: Spacing around operator function definitions

Felix Mauch via cfe-users cfe-users at lists.llvm.org
Fri Apr 8 00:13:45 PDT 2016


Hi all,

I recently stumbled across clang-format and I really like it so far :)
However, I was not able to reproduce some of our csg guidelines. Maybe I 
was too stupid configuring this, but as far as I can see those things 
are not working atm (I am using version 3.6), am I right?

1. Spacing around operator function definitions
At my company we like to ad spaces around the operators when defining 
operator functions, for example:

// Note the spaces around '==':
bool operator == (const Type& other) const
{
   return (m_member == other.m_member);
}

I could not find anything handling this kind of stuff in clang-format. I 
also gave it a shot to quickly grep through the sourcecode, but couldn't 
find anything either. Is this simply not possible? What would be the 
starting point for implementing this?

2. Initializer lists each in one line, comma at the end
I wasn't able to reproduce this. Either everything was in a separate 
line, with the comma aligned to the colon, or if possible the 
initializer list was wrapped into one line. I agree, that the 
comma-colon-aligning makes sense, however it does not fit our csg ;)
Is it possible to force putting every member into a separate line but 
keeping the comma at the end?

Cheers
Felix



More information about the cfe-users mailing list