Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
d92038eb
Commit
d92038eb
authored
Jul 19, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix subtle bug in KJ_DEFER that didn't come up in practice due to RVO.
parent
8bfe482a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
common.h
c++/src/kj/common.h
+10
-2
No files found.
c++/src/kj/common.h
View file @
d92038eb
...
...
@@ -728,10 +728,18 @@ namespace _ { // private
template
<
typename
Func
>
class
Deferred
{
public
:
inline
Deferred
(
Func
func
)
:
func
(
func
)
{}
inline
~
Deferred
()
{
func
();
}
inline
Deferred
(
Func
func
)
:
func
(
func
),
canceled
(
false
)
{}
inline
~
Deferred
()
{
if
(
!
canceled
)
func
();
}
KJ_DISALLOW_COPY
(
Deferred
);
// This move constructor is optimized away by the compiler in practice. It is only here for
// technical correctness.
inline
Deferred
(
Deferred
&&
other
)
:
func
(
kj
::
mv
(
other
.
func
))
{
other
.
canceled
=
true
;
}
private
:
Func
func
;
bool
canceled
;
};
template
<
typename
Func
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment