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
83db896d
Commit
83db896d
authored
Mar 11, 2021
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Silence deprecation warnings for std::byte
parent
1b29bf10
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
2 deletions
+79
-2
CHANGELOG.md
CHANGELOG.md
+1
-0
libcaf_core/caf/inspector_access.hpp
libcaf_core/caf/inspector_access.hpp
+18
-0
libcaf_core/caf/inspector_access_base.hpp
libcaf_core/caf/inspector_access_base.hpp
+1
-2
libcaf_core/test/load_inspector.cpp
libcaf_core/test/load_inspector.cpp
+29
-0
libcaf_core/test/save_inspector.cpp
libcaf_core/test/save_inspector.cpp
+30
-0
No files found.
CHANGELOG.md
View file @
83db896d
...
@@ -26,6 +26,7 @@ is based on [Keep a Changelog](https://keepachangelog.com).
...
@@ -26,6 +26,7 @@ is based on [Keep a Changelog](https://keepachangelog.com).
-
Passing a function reference to the constructor of an actor caused a compiler
-
Passing a function reference to the constructor of an actor caused a compiler
error when building with logging enabled. CAF now properly handles this edge
error when building with logging enabled. CAF now properly handles this edge
case and logs such constructor arguments as
`<unprintable>`
(#1229).
case and logs such constructor arguments as
`<unprintable>`
(#1229).
-
Silence a deprecated-enum-conversion warning for
`std::byte`
(#1230).
## [0.18.0] - 2021-01-25
## [0.18.0] - 2021-01-25
...
...
libcaf_core/caf/inspector_access.hpp
View file @
83db896d
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#pragma once
#pragma once
#include <chrono>
#include <chrono>
#include <cstddef>
#include <memory>
#include <memory>
#include <tuple>
#include <tuple>
#include <utility>
#include <utility>
...
@@ -475,6 +476,23 @@ struct inspector_access<std::unique_ptr<error::data>>
...
@@ -475,6 +476,23 @@ struct inspector_access<std::unique_ptr<error::data>>
// nop
// nop
};
};
// -- inspection support for std::byte -----------------------------------------
#ifdef __cpp_lib_byte
template
<
>
struct
inspector_access
<
std
::
byte
>
:
inspector_access_base
<
std
::
byte
>
{
template
<
class
Inspector
>
[[
nodiscard
]]
static
bool
apply
(
Inspector
&
f
,
std
::
byte
&
x
)
{
using
integer_type
=
std
::
underlying_type_t
<
std
::
byte
>
;
auto
get
=
[
&
x
]
{
return
static_cast
<
integer_type
>
(
x
);
};
auto
set
=
[
&
x
](
integer_type
val
)
{
x
=
static_cast
<
std
::
byte
>
(
val
);
};
return
f
.
apply
(
get
,
set
);
}
};
#endif
// -- inspection support for variant<Ts...> ------------------------------------
// -- inspection support for variant<Ts...> ------------------------------------
template
<
class
T
>
template
<
class
T
>
...
...
libcaf_core/caf/inspector_access_base.hpp
View file @
83db896d
...
@@ -10,8 +10,7 @@
...
@@ -10,8 +10,7 @@
namespace
caf
{
namespace
caf
{
/// Provides default implementations for `save_field`, `load_field`, and
/// Provides default implementations for `save_field` and `load_field`.
/// `apply_value`.
template
<
class
T
>
template
<
class
T
>
struct
inspector_access_base
{
struct
inspector_access_base
{
/// Loads a mandatory field from `f`.
/// Loads a mandatory field from `f`.
...
...
libcaf_core/test/load_inspector.cpp
View file @
83db896d
...
@@ -746,4 +746,33 @@ end object)_";
...
@@ -746,4 +746,33 @@ end object)_";
}
}
}
}
#ifdef __cpp_lib_byte
SCENARIO
(
"load inspectors support std::byte"
)
{
GIVEN
(
"a struct with std::byte"
)
{
struct
byte_test
{
std
::
byte
v1
=
std
::
byte
{
0
};
optional
<
std
::
byte
>
v2
;
};
auto
x
=
byte_test
{};
WHEN
(
"inspecting the struct"
)
{
THEN
(
"CAF treats std::byte like an unsigned integer"
)
{
CHECK
(
f
.
object
(
x
).
fields
(
f
.
field
(
"v1"
,
x
.
v1
),
f
.
field
(
"v2"
,
x
.
v2
)));
CHECK
(
!
f
.
get_error
());
std
::
string
baseline
=
R"_(
begin object anonymous
begin field v1
uint8_t value
end field
begin optional field v2
end field
end object)_"
;
CHECK_EQ
(
f
.
log
,
baseline
);
}
}
}
}
#endif
CAF_TEST_FIXTURE_SCOPE_END
()
CAF_TEST_FIXTURE_SCOPE_END
()
libcaf_core/test/save_inspector.cpp
View file @
83db896d
...
@@ -783,4 +783,34 @@ end object)_");
...
@@ -783,4 +783,34 @@ end object)_");
}
}
}
}
#ifdef __cpp_lib_byte
SCENARIO
(
"save inspectors support std::byte"
)
{
GIVEN
(
"a struct with std::byte"
)
{
struct
byte_test
{
std
::
byte
v1
;
optional
<
std
::
byte
>
v2
;
};
auto
x
=
byte_test
{
std
::
byte
{
1
},
std
::
byte
{
2
}};
WHEN
(
"inspecting the struct"
)
{
THEN
(
"CAF treats std::byte like an unsigned integer"
)
{
CHECK
(
f
.
object
(
x
).
fields
(
f
.
field
(
"v1"
,
x
.
v1
),
f
.
field
(
"v2"
,
x
.
v2
)));
CHECK
(
!
f
.
get_error
());
std
::
string
baseline
=
R"_(
begin object anonymous
begin field v1
uint8_t value
end field
begin optional field v2
uint8_t value
end field
end object)_"
;
CHECK_EQ
(
f
.
log
,
baseline
);
}
}
}
}
#endif
CAF_TEST_FIXTURE_SCOPE_END
()
CAF_TEST_FIXTURE_SCOPE_END
()
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