c++formattinguncrustify

Uncrustify: Add new line after angle bracket in multi line typedef using a template


Using the Uncrustify tool I am looking for a rule to add a new line after an opening angle bracket if the opening and the closing angle bracket are not on the same line. In other words I would like to put a new line before the first argument of a C++ template if the line is getting to long (means > 140 columns in my case).

There are comparable rules for this in Uncrustify for function definition/declaration/call. https://stackoverflow.com/a/42254773/1288118

Is there any rule available in Uncrustify for this use case?

Input

typedef ::foo::moon::extra::common::super::VeryLongClassName < ::foo::moon::extra::common::super::ISuperNice ,::foo::moon::extra::common::super::NiceStoryAboutTheSea ,::foo::moon::extra::common::super::TheVeryLastParameter >  AVeryLongNameForDemonstration;

Expected output

typedef ::foo::moon::extra::common::super::VeryLongClassName<
   ::foo::moon::extra::common::super::ISuperNice,
   ::foo::moon::extra::common::super::NiceStoryAboutTheSea,
   ::foo::moon::extra::common::super::TheVeryLastParameter>  AVeryLongNameForDemonstration;

Solution

  • No, currently there are no similar options for templates.

    You can however open up a feature request or better yet, submit a PR for that at https://github.com/uncrustify/uncrustify.