Menu ▾ ▴

#516 Format C++11 initializer lists

closed-fixed
None
2023-05-19
2018-11-29
Flash
No

astyle needs to understand the difference between code blocks and initializer lists.

My project config file includes:

--style=1tbs                            # One True Brace. Linux braces, add braces to all conditionals (-A10)
--style=break                           # Broken braces (-A1)

--indent=spaces=4                       # set indentation to 4 spaces
--indent-switches                       # indent case from switch
--break-blocks                          # add blank lines before blocks (e.g., if, while, for)
--keep-one-line-blocks
--keep-one-line-statements

--break-return-type                     # put the return type of a function on a separate line

--pad-oper                              # add spaces around operators
--pad-header                            # add spaces after paren headers (e.g., if, while, for)

--align-pointer=type                    # int *pInt; --> int* pInt;
--convert-tabs                          # convert tabs to spaces
--max-code-length=120                   # break lines at 120 characters
--break-after-logical                   # when breaking long lines, leave logical operators on first line

However, this is incompatible with sane handling of initializer lists:

auto const mask_fore    = uint8_t{0x01};
auto const mask_aft     = uint8_t{0x02};
auto const mask_roof    = uint8_t{0x04};

becomes

auto const mask_fore    = uint8_t
{
    0x01
};
auto const mask_aft     = uint8_t
{
    0x02
};
auto const mask_roof    = uint8_t
{
    0x04
};

which is ridiculous.

Discussion

  • André Simon

    André Simon - 2023-02-05
    • status: open --> open-accepted
    • assigned_to: André Simon
     
  • André Simon

    André Simon - 2023-02-05

    Did you apply more options? Using this project file the formatting is not being changed.

     
  • André Simon

    André Simon - 2023-04-16
    • status: open-accepted --> open-fixed
     
  • André Simon

    André Simon - 2023-04-16

    This was fixed in 3.3-beta1.

     
  • André Simon

    André Simon - 2023-05-19
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.