Equivalent of #region for C++

前端 未结 10 1164
無奈伤痛
無奈伤痛 2020-12-24 04:17

What\'s the C++ equivalent of #region for C++ so I can put in custom code collapsible bits and make my code a little easier to read?

10条回答
  •  伪装坚强ぢ
    2020-12-24 05:06

    The first answer from this question mentions another alternative. It is not applicable in all situations, though.

    Method: Use {...} instead which natively supports code collapsing in Visual Studio.

    1. Enable option: Tools -> Options -> Text Editor -> C/C++ -> Formatting -> OutLine Statement Blocks -> True.

    2. Put your in different scopes {...}, then it will collapse the code in different scopes:

    Scoped code collapsing example

提交回复
热议问题