Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
16cc8501
Commit
16cc8501
authored
Jun 19, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use addressof to guard against awful types
parent
502a5c95
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
15 deletions
+17
-15
libcaf_core/caf/expected.hpp
libcaf_core/caf/expected.hpp
+13
-13
libcaf_core/caf/optional.hpp
libcaf_core/caf/optional.hpp
+2
-1
libcaf_core/caf/variant.hpp
libcaf_core/caf/variant.hpp
+2
-1
No files found.
libcaf_core/caf/expected.hpp
View file @
16cc8501
...
@@ -68,23 +68,23 @@ public:
...
@@ -68,23 +68,23 @@ public:
expected
(
U
x
,
expected
(
U
x
,
typename
std
::
enable_if
<
std
::
is_convertible
<
U
,
T
>::
value
>::
type
*
=
nullptr
)
typename
std
::
enable_if
<
std
::
is_convertible
<
U
,
T
>::
value
>::
type
*
=
nullptr
)
:
engaged_
(
true
)
{
:
engaged_
(
true
)
{
new
(
&
value_
)
T
(
std
::
move
(
x
));
new
(
std
::
addressof
(
value_
)
)
T
(
std
::
move
(
x
));
}
}
expected
(
T
&&
x
)
noexcept
(
nothrow_move
)
:
engaged_
(
true
)
{
expected
(
T
&&
x
)
noexcept
(
nothrow_move
)
:
engaged_
(
true
)
{
new
(
&
value_
)
T
(
std
::
move
(
x
));
new
(
std
::
addressof
(
value_
)
)
T
(
std
::
move
(
x
));
}
}
expected
(
const
T
&
x
)
noexcept
(
nothrow_copy
)
:
engaged_
(
true
)
{
expected
(
const
T
&
x
)
noexcept
(
nothrow_copy
)
:
engaged_
(
true
)
{
new
(
&
value_
)
T
(
x
);
new
(
std
::
addressof
(
value_
)
)
T
(
x
);
}
}
expected
(
caf
::
error
e
)
noexcept
:
engaged_
(
false
)
{
expected
(
caf
::
error
e
)
noexcept
:
engaged_
(
false
)
{
new
(
&
error_
)
caf
::
error
{
std
::
move
(
e
)};
new
(
std
::
addressof
(
error_
)
)
caf
::
error
{
std
::
move
(
e
)};
}
}
expected
(
no_error_t
)
noexcept
:
engaged_
(
false
)
{
expected
(
no_error_t
)
noexcept
:
engaged_
(
false
)
{
new
(
&
error_
)
caf
::
error
{};
new
(
std
::
addressof
(
error_
)
)
caf
::
error
{};
}
}
expected
(
const
expected
&
other
)
noexcept
(
nothrow_copy
)
{
expected
(
const
expected
&
other
)
noexcept
(
nothrow_copy
)
{
...
@@ -93,7 +93,7 @@ public:
...
@@ -93,7 +93,7 @@ public:
template
<
class
Code
,
class
E
=
enable_if_has_make_error_t
<
Code
>
>
template
<
class
Code
,
class
E
=
enable_if_has_make_error_t
<
Code
>
>
expected
(
Code
code
)
:
engaged_
(
false
)
{
expected
(
Code
code
)
:
engaged_
(
false
)
{
new
(
&
error_
)
caf
::
error
(
make_error
(
code
));
new
(
std
::
addressof
(
error_
)
)
caf
::
error
(
make_error
(
code
));
}
}
expected
(
expected
&&
other
)
noexcept
(
nothrow_move
)
{
expected
(
expected
&&
other
)
noexcept
(
nothrow_move
)
{
...
@@ -134,7 +134,7 @@ public:
...
@@ -134,7 +134,7 @@ public:
}
else
{
}
else
{
destroy
();
destroy
();
engaged_
=
true
;
engaged_
=
true
;
new
(
&
value_
)
T
(
x
);
new
(
std
::
addressof
(
value_
)
)
T
(
x
);
}
}
return
*
this
;
return
*
this
;
}
}
...
@@ -146,7 +146,7 @@ public:
...
@@ -146,7 +146,7 @@ public:
}
else
{
}
else
{
destroy
();
destroy
();
engaged_
=
true
;
engaged_
=
true
;
new
(
&
value_
)
T
(
std
::
move
(
x
));
new
(
std
::
addressof
(
value_
)
)
T
(
std
::
move
(
x
));
}
}
return
*
this
;
return
*
this
;
}
}
...
@@ -163,7 +163,7 @@ public:
...
@@ -163,7 +163,7 @@ public:
else
{
else
{
destroy
();
destroy
();
engaged_
=
false
;
engaged_
=
false
;
new
(
&
error_
)
caf
::
error
(
std
::
move
(
e
));
new
(
std
::
addressof
(
error_
)
)
caf
::
error
(
std
::
move
(
e
));
}
}
return
*
this
;
return
*
this
;
}
}
...
@@ -248,17 +248,17 @@ public:
...
@@ -248,17 +248,17 @@ public:
private:
private:
void
construct
(
expected
&&
other
)
noexcept
(
nothrow_move
)
{
void
construct
(
expected
&&
other
)
noexcept
(
nothrow_move
)
{
if
(
other
.
engaged_
)
if
(
other
.
engaged_
)
new
(
&
value_
)
T
(
std
::
move
(
other
.
value_
));
new
(
std
::
addressof
(
value_
)
)
T
(
std
::
move
(
other
.
value_
));
else
else
new
(
&
error_
)
caf
::
error
(
std
::
move
(
other
.
error_
));
new
(
std
::
addressof
(
error_
)
)
caf
::
error
(
std
::
move
(
other
.
error_
));
engaged_
=
other
.
engaged_
;
engaged_
=
other
.
engaged_
;
}
}
void
construct
(
const
expected
&
other
)
noexcept
(
nothrow_copy
)
{
void
construct
(
const
expected
&
other
)
noexcept
(
nothrow_copy
)
{
if
(
other
.
engaged_
)
if
(
other
.
engaged_
)
new
(
&
value_
)
T
(
other
.
value_
);
new
(
std
::
addressof
(
value_
)
)
T
(
other
.
value_
);
else
else
new
(
&
error_
)
caf
::
error
(
other
.
error_
);
new
(
std
::
addressof
(
error_
)
)
caf
::
error
(
other
.
error_
);
engaged_
=
other
.
engaged_
;
engaged_
=
other
.
engaged_
;
}
}
...
...
libcaf_core/caf/optional.hpp
View file @
16cc8501
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#pragma once
#pragma once
#include <memory>
#include <new>
#include <new>
#include <utility>
#include <utility>
...
@@ -157,7 +158,7 @@ class optional {
...
@@ -157,7 +158,7 @@ class optional {
void
cr
(
V
&&
x
)
{
void
cr
(
V
&&
x
)
{
CAF_ASSERT
(
!
m_valid
);
CAF_ASSERT
(
!
m_valid
);
m_valid
=
true
;
m_valid
=
true
;
new
(
&
m_value
)
T
(
std
::
forward
<
V
>
(
x
));
new
(
std
::
addressof
(
m_value
)
)
T
(
std
::
forward
<
V
>
(
x
));
}
}
bool
m_valid
;
bool
m_valid
;
...
...
libcaf_core/caf/variant.hpp
View file @
16cc8501
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#pragma once
#pragma once
#include <functional>
#include <functional>
#include <memory>
#include <type_traits>
#include <type_traits>
#include "caf/config.hpp"
#include "caf/config.hpp"
...
@@ -280,7 +281,7 @@ private:
...
@@ -280,7 +281,7 @@ private:
destroy_data
();
destroy_data
();
type_
=
type_id
;
type_
=
type_id
;
auto
&
ref
=
data_
.
get
(
token
);
auto
&
ref
=
data_
.
get
(
token
);
new
(
&
ref
)
type
(
std
::
forward
<
U
>
(
arg
));
new
(
std
::
addressof
(
ref
)
)
type
(
std
::
forward
<
U
>
(
arg
));
}
else
{
}
else
{
data_
.
get
(
token
)
=
std
::
forward
<
U
>
(
arg
);
data_
.
get
(
token
)
=
std
::
forward
<
U
>
(
arg
);
}
}
...
...
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