File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ set(sources
23
23
SwarmHash.h
24
24
UTF8.cpp
25
25
UTF8.h
26
+ Utils.h
26
27
vector_ref.h
27
28
Visitor.h
28
29
Whiskers.cpp
Original file line number Diff line number Diff line change
1
+ /*
2
+ This file is part of solidity.
3
+
4
+ solidity is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU General Public License as published by
6
+ the Free Software Foundation, either version 3 of the License, or
7
+ (at your option) any later version.
8
+
9
+ solidity is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with solidity. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ namespace dev
19
+ {
20
+
21
+ // / Increments @p incrementable and ensures it is getting decremented upon destruction of the returned value.
22
+ // /
23
+ // / Use this to ensure scoped increments/decrements in your code.
24
+ template <typename Incrementable>
25
+ auto inline scopedIncrement (Incrementable& incrementable)
26
+ {
27
+ struct ScopedIncrement {
28
+ Incrementable& value;
29
+ ~ScopedIncrement () { --value; }
30
+ };
31
+ return ScopedIncrement{ ++incrementable };
32
+ }
33
+
34
+ template <typename Callable>
35
+ auto inline atScopeExit (Callable callable)
36
+ {
37
+ struct ExitCode {
38
+ T leave;
39
+ ~ExitCode () { leave (); }
40
+ };
41
+ return ExitCode{ std::move (leave) };
42
+ }
43
+
44
+ } // namespace dev
You can’t perform that action at this time.
0 commit comments