c++clang-format

Clang format - add space before angled bracket


I would like a space in-between std::unique_ptr and <boost::thread> in this line:

std::unique_ptr<boost::thread> my_thread;

You would think SpaceAfterTemplateKeyword: true would work, but it doesn't. I don't see any other SpaceBefore or SpaceAfter options that would help me (I have tried them).

Clang-Format Style Options

Thank you.


Solution

  • No, you don't want a space there. We don't put a space in that position in C++. Therefore, clang-format (which is designed to format C++ code) doesn't provide any way to do that, any more than it would provide a way to change all identifiers into UPPERCASE or put each token on a line by itself or anything else that's not directly useful to formatting C++ code.

    FYI, I believe the SpaceAfterTemplateKeyword option controls the spacing in

    template<class T> void f();
    template <class T> void f();