Menu

#317 Issue with lambda functions with explicit return type.

closed-fixed
2023-06-30
2014-10-27
No

Hello,

AStyle seems to be confused by lambda functions with explicit return type. It doesn't follow the expected "curly bracket policy" inside the lambda body. Additionally I think the -> notation should be treated as an operator and padded accordingly but that's arguable I guess.

Attached are a sample source file and the configuration file that can be used to reproduce.

Best regards,
Underground78

2 Attachments

Discussion

  • Andrew Wall

    Andrew Wall - 2017-11-17

    This issue has not been fixed yet.

    I've only just been able to start developing with c++11/17 and so I've just been wondering why VS2017 keeps formatting my code wrongly.

    There is no problem in this case:
    namespace foo {
    auto INST = { return false; };
    class bar {};
    }

    In this case the second lambda is messy and class bar is no longer indented:
    namespace foo {
    auto INST = { return false; };
    auto INST2 = -> bool {
    if(a == 0) { return true; }
    return false;
    };
    class bar {};
    }

    I expected the second snippet to be formatted like this:
    namespace foo {
    auto INST = { return false; };
    auto INST2 = -> bool {
    if(a == 0) { return true; }
    return false;
    };
    class bar {};
    }

     

    Last edit: Andrew Wall 2017-11-20
  • André Simon

    André Simon - 2023-06-30
    • status: open --> closed-fixed
    • assigned_to: André Simon
     
  • André Simon

    André Simon - 2023-06-30

    This was fixed in a recent release.

     

Log in to post a comment.