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
043151fa
Commit
043151fa
authored
Feb 25, 2020
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add make_typed_behavior convenience function
parent
3d4021b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
0 deletions
+47
-0
libcaf_core/CMakeLists.txt
libcaf_core/CMakeLists.txt
+1
-0
libcaf_core/caf/typed_behavior.hpp
libcaf_core/caf/typed_behavior.hpp
+6
-0
libcaf_core/test/typed_behavior.cpp
libcaf_core/test/typed_behavior.cpp
+40
-0
No files found.
libcaf_core/CMakeLists.txt
View file @
043151fa
...
...
@@ -273,6 +273,7 @@ set(CAF_CORE_TEST_SOURCES
test/tracing_data.cpp
test/type_erased_tuple.cpp
test/type_id_list.cpp
test/typed_behavior.cpp
test/typed_message_view.cpp
test/typed_response_promise.cpp
test/typed_spawn.cpp
...
...
libcaf_core/caf/typed_behavior.hpp
View file @
043151fa
...
...
@@ -253,4 +253,10 @@ struct is_typed_behavior : std::false_type {};
template
<
class
...
Sigs
>
struct
is_typed_behavior
<
typed_behavior
<
Sigs
...
>>
:
std
::
true_type
{};
/// Creates a typed behavior from given function objects.
template
<
class
...
Fs
>
typed_behavior
<
deduce_mpi_t
<
Fs
>
...
>
make_typed_behavior
(
Fs
...
fs
)
{
return
{
std
::
move
(
fs
)...};
}
}
// namespace caf
libcaf_core/test/typed_behavior.cpp
0 → 100644
View file @
043151fa
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2020 Dominik Charousset *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#define CAF_SUITE typed_behavior
#include "caf/typed_behavior.hpp"
#include "caf/test/dsl.hpp"
#include <cstdint>
#include <string>
#include "caf/typed_actor.hpp"
using
namespace
caf
;
CAF_TEST
(
make_typed_behavior
automatically
deduces
its
types
)
{
using
handle
=
typed_actor
<
reacts_to
<
std
::
string
>
,
replies_to
<
int32_t
>::
with
<
int32_t
>
,
replies_to
<
double
>::
with
<
double
>>
;
auto
bhvr
=
make_typed_behavior
([](
const
std
::
string
&
)
{},
[](
int32_t
x
)
{
return
x
;
},
[](
double
x
)
{
return
x
;
});
static_assert
(
std
::
is_same
<
handle
::
behavior_type
,
decltype
(
bhvr
)
>::
value
);
}
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