Skip to content

Commit 894f73b

Browse files
Fix formatting to pass with checks
1 parent b6eca02 commit 894f73b

File tree

2 files changed

+18
-26
lines changed

2 files changed

+18
-26
lines changed

.clang-format

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,22 @@ BinPackParameters: false
5757
BitFieldColonSpacing: Both
5858
BraceWrapping:
5959
AfterCaseLabel: false
60-
AfterClass: false
60+
AfterClass: true
6161
AfterControlStatement: Never
6262
AfterEnum: false
6363
AfterExternBlock: false
64-
AfterFunction: false
64+
AfterFunction: true
6565
AfterNamespace: false
6666
AfterObjCDeclaration: false
67-
AfterStruct: false
68-
AfterUnion: false
69-
BeforeCatch: false
70-
BeforeElse: false
67+
AfterStruct: true
68+
AfterUnion: true
69+
BeforeCatch: true
70+
BeforeElse: true
7171
BeforeLambdaBody: false
7272
BeforeWhile: false
7373
IndentBraces: false
74-
SplitEmptyFunction: true
75-
SplitEmptyRecord: true
74+
SplitEmptyFunction: false
75+
SplitEmptyRecord: false
7676
SplitEmptyNamespace: true
7777
BreakAfterAttributes: Never
7878
BreakAfterJavaFieldAnnotations: false

examples/scope_example.cpp

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
void print_exit_status(std::string_view name, bool exit_status, bool did_throw)
99
{
1010
std::cout << name << ":\n";
11-
std::cout << " Throwed exception " << (did_throw ? "yes" : "no") << "\n";
12-
std::cout << " Exit status " << (exit_status ? "finished" : "pending") << "\n\n";
11+
std::cout << " Exception thrown: " << (did_throw ? "yes" : "no") << "\n";
12+
std::cout << " Exit status: " << (exit_status ? "finished" : "pending") << "\n\n";
1313
}
1414

1515
// Randomly throw an exception (50% chance)
@@ -24,52 +24,44 @@ int main()
2424
bool exit_status{false}, did_throw{false};
2525

2626
// Manual handling at "end of scope"
27-
try
28-
{
27+
try {
2928
maybe_throw();
3029
exit_status = true;
3130
}
32-
catch (...)
33-
{
31+
catch (...) {
3432
did_throw = true;
3533
}
3634
print_exit_status("Manual handling", exit_status, did_throw);
3735

3836
// Using scope_exit: runs on scope exit (success or exception)
3937
exit_status = did_throw = false;
40-
try
41-
{
38+
try {
4239
auto guard = std::experimental::scope_exit{[&] { exit_status = true; }};
4340
maybe_throw();
4441
}
45-
catch (...)
46-
{
42+
catch (...) {
4743
did_throw = true;
4844
}
4945
print_exit_status("scope_exit", exit_status, did_throw);
5046

5147
// Using scope_fail: runs only if an exception occurs
5248
exit_status = did_throw = false;
53-
try
54-
{
49+
try {
5550
auto guard = std::experimental::scope_fail{[&] { exit_status = true; }};
5651
maybe_throw();
5752
}
58-
catch (...)
59-
{
53+
catch (...) {
6054
did_throw = true;
6155
}
6256
print_exit_status("scope_fail", exit_status, did_throw);
6357

6458
// Using scope_success: runs only if no exception occurs
6559
exit_status = did_throw = false;
66-
try
67-
{
60+
try {
6861
auto guard = std::experimental::scope_success{[&] { exit_status = true; }};
6962
maybe_throw();
7063
}
71-
catch (...)
72-
{
64+
catch (...) {
7365
did_throw = true;
7466
}
7567
print_exit_status("scope_success", exit_status, did_throw);

0 commit comments

Comments
 (0)