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
6a60637a
Commit
6a60637a
authored
Sep 04, 2013
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
return result from partial_function and behavior
parent
b7c862a4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
8 deletions
+15
-8
cppa/behavior.hpp
cppa/behavior.hpp
+3
-3
cppa/partial_function.hpp
cppa/partial_function.hpp
+3
-3
unit_testing/test_match.cpp
unit_testing/test_match.cpp
+9
-2
No files found.
cppa/behavior.hpp
View file @
6a60637a
...
...
@@ -101,7 +101,7 @@ class behavior {
* @copydoc partial_function::operator()()
*/
template
<
typename
T
>
inline
bool
operator
()(
T
&&
arg
);
inline
optional
<
any_tuple
>
operator
()(
T
&&
arg
);
/**
* @brief Adds a continuation to this behavior that is executed
...
...
@@ -159,8 +159,8 @@ inline const util::duration& behavior::timeout() const {
}
template
<
typename
T
>
inline
bool
behavior
::
operator
()(
T
&&
arg
)
{
return
(
m_impl
)
&&
m_impl
->
invoke
(
std
::
forward
<
T
>
(
arg
))
;
inline
optional
<
any_tuple
>
behavior
::
operator
()(
T
&&
arg
)
{
return
(
m_impl
)
?
m_impl
->
invoke
(
std
::
forward
<
T
>
(
arg
))
:
none
;
}
...
...
cppa/partial_function.hpp
View file @
6a60637a
...
...
@@ -99,7 +99,7 @@ class partial_function {
* does <b>not</b> evaluate guards.
*/
template
<
typename
T
>
inline
bool
operator
()(
T
&&
arg
);
inline
optional
<
any_tuple
>
operator
()(
T
&&
arg
);
/**
* @brief Adds a fallback which is used where
...
...
@@ -162,8 +162,8 @@ inline bool partial_function::defined_at(const any_tuple& value) {
}
template
<
typename
T
>
inline
bool
partial_function
::
operator
()(
T
&&
arg
)
{
return
(
m_impl
)
&&
m_impl
->
invoke
(
std
::
forward
<
T
>
(
arg
))
;
inline
optional
<
any_tuple
>
partial_function
::
operator
()(
T
&&
arg
)
{
return
(
m_impl
)
?
m_impl
->
invoke
(
std
::
forward
<
T
>
(
arg
))
:
none
;
}
template
<
typename
...
Ts
>
...
...
unit_testing/test_match.cpp
View file @
6a60637a
...
...
@@ -171,7 +171,14 @@ int main() {
CPPA_CHECK_EQUAL
(
expr19
(
expr19_tup
),
2
);
partial_function
expr20
=
expr19
;
enable_case1
=
false
;
CPPA_CHECK_EQUAL
(
expr20
(
expr19_tup
),
1
);
CPPA_CHECK
(
expr20
(
expr19_tup
)
==
make_any_tuple
(
1
));
partial_function
expr21
{
on
(
atom
(
"add"
),
arg_match
)
>>
[](
int
a
,
int
b
)
{
return
a
+
b
;
}
};
CPPA_CHECK
(
expr21
(
make_any_tuple
(
atom
(
"add"
),
1
,
2
))
==
make_any_tuple
(
3
));
CPPA_CHECK
(
!
expr21
(
make_any_tuple
(
atom
(
"sub"
),
1
,
2
)));
}
/* test 'match' function */
{
auto
res0
=
match
(
5
)
(
...
...
@@ -277,7 +284,7 @@ int main() {
std
::
string
last_invoked_fun
;
# define bhvr_check(pf, tup, expected_result, str) { \
last_invoked_fun = ""; \
CPPA_CHECK_EQUAL(
pf(tup), expected_result);
\
CPPA_CHECK_EQUAL(
static_cast<bool>(pf(tup)), expected_result);
\
CPPA_CHECK_EQUAL(last_invoked_fun, str); \
}
/* test if match hints are evaluated properly */
{
...
...
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