1- ---
2- Language : Cpp
3- Standard : Latest
1+ # -----------------------------------------------------------------------------
2+ # mcpp-community C++ Style Configuration
3+ #
4+ # This configuration follows the style specification defined in:
5+ # https://github.com/mcpp-community/mcpp-style-ref
6+ #
7+ # Maintained by: mcpp-community
8+ # -----------------------------------------------------------------------------
49
5- IndentWidth : 4 # 缩进宽度:4空格
6- TabWidth : 4 # Tab宽度:4空格
7- UseTab : Never # 不使用Tab,只用空格
8- AccessModifierOffset : -4 # 访问修饰符(public/private)向左缩进4空格
10+ Language : Cpp # Apply configuration to C++
911
10- BreakBeforeBraces : Attach # 大括号附加在声明同行(如 if (x) {)
1112
12- PointerAlignment : Left # 指针/引用符号紧贴类型(int* p)
13+ # -----------------------------------------------------------------------------
14+ # Language Standard
15+ # -----------------------------------------------------------------------------
16+ Standard : Latest # Always use the latest supported C++ standard
1317
14- SpaceBeforeCpp11BracedList : true # 在 ) 和 { 之间加空格:func( {1, 2} )
15- Cpp11BracedListStyle : false # 保留 {} 内部空格:{ 1, 2, 3 }
1618
17- AlwaysBreakTemplateDeclarations : Yes # 模板声明总是换行:template<typename T>\nclass X
19+ # -----------------------------------------------------------------------------
20+ # Indentation
21+ # -----------------------------------------------------------------------------
22+ IndentWidth : 4 # Use 4 spaces for indentation
23+ TabWidth : 4 # Visual width of tab
24+ UseTab : Never # Never use tabs
1825
19- AllowShortFunctionsOnASingleLine : Empty # 只有空函数可以单行
26+
27+ # -----------------------------------------------------------------------------
28+ # Line Width
29+ # -----------------------------------------------------------------------------
30+ ColumnLimit : 100 # Maximum line width
31+
32+
33+ # -----------------------------------------------------------------------------
34+ # Spaces
35+ # -----------------------------------------------------------------------------
36+ SpaceBeforeParens : Never # No space before function call parentheses
37+ SpacesInContainerLiterals : true # Enforce spaces in container literals
38+ SpaceBeforeAssignmentOperators : true # Add space before assignment operators
39+ SpacesInParentheses : false # No extra spaces inside parentheses
40+ PointerAlignment : Left # Pointer/reference attaches to type
41+ QualifierAlignment : Left # Place qualifiers like const to the left
42+
43+
44+ # -----------------------------------------------------------------------------
45+ # Braces
46+ # -----------------------------------------------------------------------------
47+ BreakBeforeBraces : Attach # Opening brace stays on same line
48+ AllowShortFunctionsOnASingleLine : Empty # Allow empty functions like `void f() {}`
49+ AllowShortIfStatementsOnASingleLine : Never # Disallow single-line if statements
50+ AllowShortBlocksOnASingleLine : Empty # Allow empty blocks on one line
51+ AllowShortLoopsOnASingleLine : false # Disallow one-line loops
52+
53+
54+ # -----------------------------------------------------------------------------
55+ # Constructor Initializer List
56+ # -----------------------------------------------------------------------------
57+ BreakConstructorInitializers : BeforeColon # Keep initializer list compact when short
58+ ConstructorInitializerAllOnOneLineOrOnePerLine : true # Allow compact initializer lists
59+ BreakConstructorInitializersBeforeComma : false # Do not break before commas
60+
61+
62+ # -----------------------------------------------------------------------------
63+ # Access Modifiers
64+ # -----------------------------------------------------------------------------
65+ AccessModifierOffset : -4 # Align access modifiers with class indentation
66+ EmptyLineBeforeAccessModifier : Never # Do not insert empty line before access specifiers
67+ EmptyLineAfterAccessModifier : Never # Do not insert empty line after access specifiers
68+
69+
70+ # -----------------------------------------------------------------------------
71+ # Namespace Formatting
72+ # -----------------------------------------------------------------------------
73+ NamespaceIndentation : None # Do not indent contents inside namespace
74+ FixNamespaceComments : true # Enforce closing namespace comments
75+ CompactNamespaces : true # Prefer namespace a::b instead of nested namespaces
76+
77+
78+ # -----------------------------------------------------------------------------
79+ # Switch / Case Formatting
80+ # -----------------------------------------------------------------------------
81+ IndentCaseLabels : true # Indent case/default labels
82+ IndentCaseBlocks : true # Indent statements inside case blocks
83+
84+
85+ # -----------------------------------------------------------------------------
86+ # Includes
87+ # -----------------------------------------------------------------------------
88+ SortIncludes : true # Automatically sort includes
89+ IncludeBlocks : Regroup # Regroup include blocks
90+ IncludeCategories :
91+ - Regex : ' ^<.*>' # Standard / third-party headers
92+ Priority : 1
93+ - Regex : ' ^".*"' # Project headers
94+ Priority : 2
95+
96+
97+ # -----------------------------------------------------------------------------
98+ # Comment Alignment
99+ # -----------------------------------------------------------------------------
100+ AlignTrailingComments : true # Align trailing comments
101+ SpacesBeforeTrailingComments : 2 # Two spaces before trailing comments
102+
103+
104+ # -----------------------------------------------------------------------------
105+ # Parameter Formatting
106+ # -----------------------------------------------------------------------------
107+ BinPackParameters : true # Allow parameters on same line
108+ BinPackArguments : true # Allow arguments on same line
109+
110+
111+ # -----------------------------------------------------------------------------
112+ # Template Formatting
113+ # -----------------------------------------------------------------------------
114+ AlwaysBreakTemplateDeclarations : Yes # Always place template declarations on their own line
115+
116+
117+ # -----------------------------------------------------------------------------
118+ # Operator Line Breaking
119+ # -----------------------------------------------------------------------------
120+ BreakBeforeBinaryOperators : None # Break after operators
121+
122+
123+ # -----------------------------------------------------------------------------
124+ # Method Chain Formatting
125+ # -----------------------------------------------------------------------------
126+ PenaltyBreakBeforeFirstCallParameter : 10000 # Avoid breaking chained calls unless necessary
127+
128+
129+ # -----------------------------------------------------------------------------
130+ # Lambda Formatting
131+ # -----------------------------------------------------------------------------
132+ AllowShortLambdasOnASingleLine : All # Allow short lambdas on one line
133+
134+
135+ # -----------------------------------------------------------------------------
136+ # Using Declarations
137+ # -----------------------------------------------------------------------------
138+ SortUsingDeclarations : true # Automatically sort using declarations
139+
140+
141+ # -----------------------------------------------------------------------------
142+ # Return Type Formatting
143+ # -----------------------------------------------------------------------------
144+ AlwaysBreakAfterReturnType : None # Break return type only when exceeding ColumnLimit
145+
146+
147+ # -----------------------------------------------------------------------------
148+ # Concepts / Requires
149+ # -----------------------------------------------------------------------------
150+ RequiresClausePosition : OwnLine # Force requires clause to a new line
151+ IndentRequiresClause : false # Do not indent requires clause
0 commit comments