Skip to content

Alignment issue when passing lambda as function parameter #1340

@ttnghia

Description

@ttnghia

Hi,

I have an alignment issue when using lambda. Usually, I have successfully set up uncrustify config and get the alignment like this:

double t    = 0; 
double t1   = 0; 
double t111 = 0;

When I write a lambda, I also get the desired effect:

auto f = [](double x) -> double
         {
             double t    = 0;
             double t1   = 0;
             double t111 = 0;

             return ...;
         };

However, when I write a lambda as a parameter passed to a function, I cannot get the assignment '=' of variables t, t1, t111 aligned anymore:

std::transform(v1.begin(), v1.end(), v2.begin(),
               [](double x) -> double
               {
                   double t = 0;
                   double t1 = 0;
                   double t111 = 0;

                   return ...;
               }; );

For nested lambda, I don't have such problem:

auto f = [](double x) -> double
         {
             auto f = [](double x) -> double
                      {
                          auto f = [](double x) -> double
                                   {
                                       double t    = 0;
                                       double t1   = 0;
                                       double t111 = 0;

                                       return ...;
                                   };

                          return ...;
                      };

             return ...;
         };

I have tried to change many parameters in the config file including align_assign_span and align_assign_thresh, but could not succeed. Did I miss something?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions