Skip to content

Commit 1f3dde8

Browse files
committed
Add OutputParameter. Fix warning in VS2022. Update clang format file for llvm 14.0.0RC1.
1 parent d07ad2b commit 1f3dde8

3 files changed

Lines changed: 102 additions & 46 deletions

File tree

_clang-format.disabled

Lines changed: 71 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,73 @@
1-
{
2-
# Disable until clang format supports closing brace on new line.
3-
# https://reviews.llvm.org/D109557
4-
Language: Cpp,
5-
AlignAfterOpenBracket: AlwaysBreak,
6-
UseTab: Never,
7-
IndentWidth: 4,
8-
BreakBeforeBraces: Allman,
9-
AllowShortIfStatementsOnASingleLine: false,
10-
IndentCaseLabels: false,
11-
ColumnLimit: 120,
1+
# Run manually to reformat a file:
2+
#
3+
# LLVM14.0.0RC1\bin\clang-format.exe -i -style=file:clang-format.txt <file>
4+
#
5+
# To reformat all files using cmd.exe:
6+
# for /r %t in (*.cc *.h) do clang-format.exe -i -style=file "%t"
7+
#
128

13-
Language: JavaScript,
14-
AlignAfterOpenBracket: AlwaysBreak,
15-
UseTab: Never,
16-
IndentWidth: 4,
17-
BreakBeforeBraces: Allman,
18-
AllowShortIfStatementsOnASingleLine: false,
19-
IndentCaseLabels: false,
20-
ColumnLimit: 200,
9+
#DisableFormat: true
10+
---
11+
BasedOnStyle: Microsoft
12+
---
13+
Language: Cpp
14+
AlignAfterOpenBracket: BlockIndent
15+
UseTab: Never
16+
IndentWidth: 4
17+
ColumnLimit: 120
18+
DerivePointerAlignment: false
19+
PointerAlignment: Left
20+
AllowShortIfStatementsOnASingleLine: false
21+
IndentCaseLabels: false
22+
AlignAfterOpenBracket: BlockIndent #DontAlign AlwaysBreak
23+
BinPackArguments: false
24+
BinPackParameters: false
25+
AllowAllArgumentsOnNextLine: false
26+
AllowAllParametersOfDeclarationOnNextLine: false
27+
AllowAllConstructorInitializersOnNextLine: false
28+
BreakConstructorInitializers: BeforeColon
29+
AllowShortLambdasOnASingleLine: true
30+
AllowShortFunctionsOnASingleLine: true
31+
AllowShortCaseLabelsOnASingleLine: true
32+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
33+
BreakBeforeBraces: AllMan #Custom
34+
BraceWrapping:
35+
BeforeLambdaBody: true
36+
AccessModifierOffset: -4
37+
IndentAccessModifiers: false
38+
---
39+
Language: JavaScript
40+
AlignAfterOpenBracket: AlwaysBreak
41+
UseTab: Never
42+
IndentWidth: 4
43+
BreakBeforeBraces: Allman
44+
AllowShortIfStatementsOnASingleLine: false
45+
IndentCaseLabels: false
46+
ColumnLimit: 200
2147

22-
#BasedOnStyle: VisualStudio,
23-
#BreakBeforeBraces: Allman,
24-
#AlignAfterOpenBracket: AlwaysBreak,
25-
#AllowShortIfStatementsOnASingleLine: false,
26-
#AllowShortCaseLabelsOnASingleLine: true,
27-
#AllowShortFunctionsOnASingleLine: true,
28-
#AlwaysBreakTemplateDeclarations: true,
29-
#ConstructorInitializerAllOnOneLineOrOnePerLine: true,
30-
#BinPackParameters: false,
31-
#IndentCaseLabels: false,
32-
#IndentWidth: 4,
33-
#TabWidth: 4,
34-
#UseTab: Never,
35-
#MaxEmptyLinesToKeep: 2,
36-
PointerAlignment: Left,
37-
## SpaceBeforeInheritanceColon: true,
38-
#SpaceBeforeParens: ControlStatements,
39-
## SpaceBeforeRangeBasedForLoopColon: true,
40-
#SpacesInSquareBrackets: false,
41-
#AllowShortIfStatementsOnASingleLine: false,
42-
#ColumnLimit: 0,
43-
#SpaceInEmptyParentheses: false,
44-
## BreakBeforeClosingBrace: true,
45-
## BreakBeforeClosingParen: true,
46-
## DanglingParenthesis: true,
47-
}
48+
---
49+
#BasedOnStyle: VisualStudio
50+
#BreakBeforeBraces: Allman
51+
#AlignAfterOpenBracket: AlwaysBreak
52+
#AllowShortIfStatementsOnASingleLine: false
53+
#AllowShortCaseLabelsOnASingleLine: true
54+
#AllowShortFunctionsOnASingleLine: true
55+
#AlwaysBreakTemplateDeclarations: true
56+
#ConstructorInitializerAllOnOneLineOrOnePerLine: true
57+
#BinPackParameters: false
58+
#IndentCaseLabels: false
59+
#IndentWidth: 4
60+
#TabWidth: 4
61+
#UseTab: Never
62+
#MaxEmptyLinesToKeep: 2
63+
#PointerAlignment: Left
64+
#SpaceBeforeInheritanceColon: true
65+
#SpaceBeforeParens: ControlStatements
66+
#SpaceBeforeRangeBasedForLoopColon: true
67+
#SpacesInSquareBrackets: false
68+
#AllowShortIfStatementsOnASingleLine: false
69+
#ColumnLimit: 0
70+
#SpaceInEmptyParentheses: false
71+
#BreakBeforeClosingBrace: true
72+
#BreakBeforeClosingParen: true
73+
#DanglingParenthesis: true

source/Common.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,36 @@ template <typename FunctorType>
118118
DismissableCleanupType<FunctorType> inline DismissableCleanup(FunctorType const& f) { return DismissableCleanupType<FunctorType>(f); }
119119

120120

121+
template <typename T>
122+
class OutputParameter
123+
{
124+
public:
125+
explicit OutputParameter(T& object)
126+
: p_(&object)
127+
{}
128+
129+
// Disable assignment because it would have totally different semantics then the other operator=
130+
// also it is really not needed
131+
OutputParameter& operator=(const OutputParameter&) = delete;
132+
133+
OutputParameter& operator=(T&& object)
134+
{
135+
*p_ = std::move(object);
136+
return *p_;
137+
}
138+
139+
private:
140+
T* p_;
141+
};
142+
143+
144+
template<typename T>
145+
OutputParameter<T> Output(T& t)
146+
{
147+
return OutputParameter<T>(t);
148+
}
149+
150+
121151
// Range of iterators that can be used in a ranged for loop.
122152
template<typename ForwardIteratorType>
123153
class iterator_range

source/MainWindow.ixx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2914,7 +2914,7 @@ MainWindow::DialogProcResult CALLBACK MainWindow::OnNotification(HWND hwnd, int
29142914
auto const& drawableObject = drawableObjects_[index];
29152915
if (drawableObject.IsPointInside(point.x, point.y))
29162916
{
2917-
clickedIndex = index;
2917+
clickedIndex = uint32_t(index);
29182918
break;
29192919
}
29202920
}

0 commit comments

Comments
 (0)