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
332f9eee
Commit
332f9eee
authored
Apr 13, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new guard and pattern matching implementation
parent
d3d55a4c
Changes
42
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
42 changed files
with
1606 additions
and
1618 deletions
+1606
-1618
Makefile.am
Makefile.am
+2
-2
benchmarks/actor_creation.cpp
benchmarks/actor_creation.cpp
+6
-6
cppa.files
cppa.files
+2
-2
cppa/actor.hpp
cppa/actor.hpp
+6
-3
cppa/any_tuple.hpp
cppa/any_tuple.hpp
+12
-4
cppa/behavior.hpp
cppa/behavior.hpp
+72
-27
cppa/cppa.hpp
cppa/cppa.hpp
+26
-12
cppa/detail/default_uniform_type_info_impl.hpp
cppa/detail/default_uniform_type_info_impl.hpp
+9
-9
cppa/detail/projection.hpp
cppa/detail/projection.hpp
+5
-0
cppa/detail/pseudo_tuple.hpp
cppa/detail/pseudo_tuple.hpp
+50
-18
cppa/detail/receive_loop_helper.hpp
cppa/detail/receive_loop_helper.hpp
+11
-24
cppa/detail/tdata.hpp
cppa/detail/tdata.hpp
+13
-10
cppa/event_based_actor_base.hpp
cppa/event_based_actor_base.hpp
+5
-11
cppa/fsm_actor.hpp
cppa/fsm_actor.hpp
+0
-1
cppa/get.hpp
cppa/get.hpp
+14
-3
cppa/guard_expr.hpp
cppa/guard_expr.hpp
+1
-2
cppa/intrusive_ptr.hpp
cppa/intrusive_ptr.hpp
+0
-1
cppa/match.hpp
cppa/match.hpp
+33
-17
cppa/match_expr.hpp
cppa/match_expr.hpp
+1007
-0
cppa/on.hpp
cppa/on.hpp
+172
-140
cppa/partial_function.hpp
cppa/partial_function.hpp
+28
-33
cppa/primitive_variant.hpp
cppa/primitive_variant.hpp
+8
-10
cppa/receive.hpp
cppa/receive.hpp
+8
-18
cppa/util/apply_tuple.hpp
cppa/util/apply_tuple.hpp
+2
-2
cppa/util/disable_if.hpp
cppa/util/disable_if.hpp
+0
-57
cppa/util/is_forward_iterator.hpp
cppa/util/is_forward_iterator.hpp
+5
-5
cppa/util/is_iterable.hpp
cppa/util/is_iterable.hpp
+2
-2
cppa/util/type_list.hpp
cppa/util/type_list.hpp
+17
-2
examples/math_actor_example.cpp
examples/math_actor_example.cpp
+1
-1
src/binary_deserializer.cpp
src/binary_deserializer.cpp
+3
-4
src/binary_serializer.cpp
src/binary_serializer.cpp
+3
-4
src/partial_function.cpp
src/partial_function.cpp
+2
-91
src/primitive_variant.cpp
src/primitive_variant.cpp
+2
-2
src/scheduler.cpp
src/scheduler.cpp
+9
-0
src/uniform_type_info.cpp
src/uniform_type_info.cpp
+3
-6
unit_testing/main.cpp
unit_testing/main.cpp
+2
-2
unit_testing/test.hpp
unit_testing/test.hpp
+8
-5
unit_testing/test__match.cpp
unit_testing/test__match.cpp
+9
-6
unit_testing/test__pattern.cpp
unit_testing/test__pattern.cpp
+0
-2
unit_testing/test__serialization.cpp
unit_testing/test__serialization.cpp
+0
-2
unit_testing/test__spawn.cpp
unit_testing/test__spawn.cpp
+5
-0
unit_testing/test__tuple.cpp
unit_testing/test__tuple.cpp
+43
-1072
No files found.
Makefile.am
View file @
332f9eee
...
@@ -122,6 +122,7 @@ nobase_library_include_HEADERS = \
...
@@ -122,6 +122,7 @@ nobase_library_include_HEADERS = \
cppa/detail/post_office_msg.hpp
\
cppa/detail/post_office_msg.hpp
\
cppa/detail/primitive_member.hpp
\
cppa/detail/primitive_member.hpp
\
cppa/detail/projection.hpp
\
cppa/detail/projection.hpp
\
cppa/detail/pseudo_tuple.hpp
\
cppa/detail/ptype_to_type.hpp
\
cppa/detail/ptype_to_type.hpp
\
cppa/detail/receive_loop_helper.hpp
\
cppa/detail/receive_loop_helper.hpp
\
cppa/detail/ref_counted_impl.hpp
\
cppa/detail/ref_counted_impl.hpp
\
...
@@ -159,6 +160,7 @@ nobase_library_include_HEADERS = \
...
@@ -159,6 +160,7 @@ nobase_library_include_HEADERS = \
cppa/intrusive_ptr.hpp
\
cppa/intrusive_ptr.hpp
\
cppa/local_actor.hpp
\
cppa/local_actor.hpp
\
cppa/match.hpp
\
cppa/match.hpp
\
cppa/match_expr.hpp
\
cppa/object.hpp
\
cppa/object.hpp
\
cppa/on.hpp
\
cppa/on.hpp
\
cppa/option.hpp
\
cppa/option.hpp
\
...
@@ -190,11 +192,9 @@ nobase_library_include_HEADERS = \
...
@@ -190,11 +192,9 @@ nobase_library_include_HEADERS = \
cppa/util/compare_tuples.hpp
\
cppa/util/compare_tuples.hpp
\
cppa/util/conjunction.hpp
\
cppa/util/conjunction.hpp
\
cppa/util/deduce_ref_type.hpp
\
cppa/util/deduce_ref_type.hpp
\
cppa/util/disable_if.hpp
\
cppa/util/disjunction.hpp
\
cppa/util/disjunction.hpp
\
cppa/util/duration.hpp
\
cppa/util/duration.hpp
\
cppa/util/element_at.hpp
\
cppa/util/element_at.hpp
\
cppa/util/enable_if.hpp
\
cppa/util/fiber.hpp
\
cppa/util/fiber.hpp
\
cppa/util/fixed_vector.hpp
\
cppa/util/fixed_vector.hpp
\
cppa/util/if_else.hpp
\
cppa/util/if_else.hpp
\
...
...
benchmarks/actor_creation.cpp
View file @
332f9eee
...
@@ -57,18 +57,18 @@ struct testee : fsm_actor<testee>
...
@@ -57,18 +57,18 @@ struct testee : fsm_actor<testee>
send
(
parent
,
atom
(
"result"
),
(
uint32_t
)
1
);
send
(
parent
,
atom
(
"result"
),
(
uint32_t
)
1
);
become_void
();
become_void
();
},
},
on
(
atom
(
"spread"
),
arg_match
)
>>
[
=
](
int
x
)
on
<
atom
(
"spread"
),
int
>
(
)
>>
[
=
](
int
x
)
{
{
any_tuple
msg
=
make_cow_tuple
(
atom
(
"spread"
),
x
-
1
);
any_tuple
msg
=
make_cow_tuple
(
atom
(
"spread"
),
x
-
1
);
spawn
(
new
testee
(
this
))
<<
msg
;
spawn
(
new
testee
(
this
))
<<
msg
;
spawn
(
new
testee
(
this
))
<<
msg
;
spawn
(
new
testee
(
this
))
<<
msg
;
become
become
(
(
on
(
atom
(
"result"
),
arg_match
)
>>
[
=
](
uint32_t
r1
)
on
<
atom
(
"result"
),
uint32_t
>
(
)
>>
[
=
](
uint32_t
r1
)
{
{
become
become
(
(
on
(
atom
(
"result"
),
arg_match
)
>>
[
=
](
uint32_t
r2
)
on
<
atom
(
"result"
),
uint32_t
>
(
)
>>
[
=
](
uint32_t
r2
)
{
{
send
(
parent
,
atom
(
"result"
),
r1
+
r2
);
send
(
parent
,
atom
(
"result"
),
r1
+
r2
);
become_void
();
become_void
();
...
@@ -89,18 +89,18 @@ void stacked_testee(actor_ptr parent)
...
@@ -89,18 +89,18 @@ void stacked_testee(actor_ptr parent)
{
{
send
(
parent
,
atom
(
"result"
),
(
uint32_t
)
1
);
send
(
parent
,
atom
(
"result"
),
(
uint32_t
)
1
);
},
},
on
(
atom
(
"spread"
),
arg_match
)
>>
[
&
](
int
x
)
on
<
atom
(
"spread"
),
int
>
(
)
>>
[
&
](
int
x
)
{
{
any_tuple
msg
=
make_cow_tuple
(
atom
(
"spread"
),
x
-
1
);
any_tuple
msg
=
make_cow_tuple
(
atom
(
"spread"
),
x
-
1
);
spawn
(
stacked_testee
,
self
)
<<
msg
;
spawn
(
stacked_testee
,
self
)
<<
msg
;
spawn
(
stacked_testee
,
self
)
<<
msg
;
spawn
(
stacked_testee
,
self
)
<<
msg
;
receive
receive
(
(
on
(
atom
(
"result"
),
arg_match
)
>>
[
&
](
uint32_t
v1
)
on
<
atom
(
"result"
),
uint32_t
>
(
)
>>
[
&
](
uint32_t
v1
)
{
{
receive
receive
(
(
on
(
atom
(
"result"
),
arg_match
)
>>
[
&
](
uint32_t
v2
)
on
<
atom
(
"result"
),
uint32_t
>
(
)
>>
[
&
](
uint32_t
v2
)
{
{
send
(
parent
,
atom
(
"result"
),
v1
+
v2
);
send
(
parent
,
atom
(
"result"
),
v1
+
v2
);
}
}
...
...
cppa.files
View file @
332f9eee
...
@@ -30,7 +30,6 @@ cppa/on.hpp
...
@@ -30,7 +30,6 @@ cppa/on.hpp
unit_testing/test__serialization.cpp
unit_testing/test__serialization.cpp
cppa/serializer.hpp
cppa/serializer.hpp
cppa/deserializer.hpp
cppa/deserializer.hpp
cppa/util/enable_if.hpp
cppa/object.hpp
cppa/object.hpp
cppa/detail/object_impl.hpp
cppa/detail/object_impl.hpp
cppa/detail/swap_bytes.hpp
cppa/detail/swap_bytes.hpp
...
@@ -76,7 +75,6 @@ src/to_uniform_name.cpp
...
@@ -76,7 +75,6 @@ src/to_uniform_name.cpp
cppa/detail/default_uniform_type_info_impl.hpp
cppa/detail/default_uniform_type_info_impl.hpp
src/object.cpp
src/object.cpp
cppa/util/comparable.hpp
cppa/util/comparable.hpp
cppa/util/disable_if.hpp
cppa/primitive_variant.hpp
cppa/primitive_variant.hpp
cppa/primitive_type.hpp
cppa/primitive_type.hpp
cppa/util/pt_token.hpp
cppa/util/pt_token.hpp
...
@@ -268,3 +266,5 @@ cppa/util/deduce_ref_type.hpp
...
@@ -268,3 +266,5 @@ cppa/util/deduce_ref_type.hpp
cppa/detail/projection.hpp
cppa/detail/projection.hpp
cppa/detail/value_guard.hpp
cppa/detail/value_guard.hpp
cppa/detail/tuple_iterator.hpp
cppa/detail/tuple_iterator.hpp
cppa/match_expr.hpp
cppa/detail/pseudo_tuple.hpp
cppa/actor.hpp
View file @
332f9eee
...
@@ -41,7 +41,6 @@
...
@@ -41,7 +41,6 @@
#include "cppa/process_information.hpp"
#include "cppa/process_information.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/enable_if.hpp"
namespace
cppa
{
namespace
cppa
{
...
@@ -94,7 +93,9 @@ class actor : public channel
...
@@ -94,7 +93,9 @@ class actor : public channel
template
<
typename
T
>
template
<
typename
T
>
bool
attach
(
std
::
unique_ptr
<
T
>&&
ptr
,
bool
attach
(
std
::
unique_ptr
<
T
>&&
ptr
,
typename
util
::
enable_if
<
std
::
is_base_of
<
attachable
,
T
>>::
type
*
=
0
);
typename
std
::
enable_if
<
std
::
is_base_of
<
attachable
,
T
>::
value
>::
type
*
=
0
);
/**
/**
* @brief Forces this actor to subscribe to the group @p what.
* @brief Forces this actor to subscribe to the group @p what.
...
@@ -238,7 +239,9 @@ inline bool actor::is_proxy() const
...
@@ -238,7 +239,9 @@ inline bool actor::is_proxy() const
template
<
typename
T
>
template
<
typename
T
>
bool
actor
::
attach
(
std
::
unique_ptr
<
T
>&&
ptr
,
bool
actor
::
attach
(
std
::
unique_ptr
<
T
>&&
ptr
,
typename
util
::
enable_if
<
std
::
is_base_of
<
attachable
,
T
>>::
type
*
)
typename
std
::
enable_if
<
std
::
is_base_of
<
attachable
,
T
>::
value
>::
type
*
)
{
{
return
attach
(
static_cast
<
attachable
*>
(
ptr
.
release
()));
return
attach
(
static_cast
<
attachable
*>
(
ptr
.
release
()));
}
}
...
...
cppa/any_tuple.hpp
View file @
332f9eee
...
@@ -31,13 +31,13 @@
...
@@ -31,13 +31,13 @@
#ifndef ANY_TUPLE_HPP
#ifndef ANY_TUPLE_HPP
#define ANY_TUPLE_HPP
#define ANY_TUPLE_HPP
#include <type_traits>
#include "cppa/cow_tuple.hpp"
#include "cppa/cow_tuple.hpp"
#include "cppa/config.hpp"
#include "cppa/config.hpp"
#include "cppa/cow_ptr.hpp"
#include "cppa/cow_ptr.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/enable_if.hpp"
#include "cppa/util/disable_if.hpp"
#include "cppa/util/is_iterable.hpp"
#include "cppa/util/is_iterable.hpp"
#include "cppa/detail/tuple_view.hpp"
#include "cppa/detail/tuple_view.hpp"
...
@@ -162,7 +162,11 @@ class any_tuple
...
@@ -162,7 +162,11 @@ class any_tuple
template
<
typename
T
>
template
<
typename
T
>
static
inline
any_tuple
view
(
T
&&
value
,
static
inline
any_tuple
view
(
T
&&
value
,
typename
util
::
enable_if
<
util
::
is_iterable
<
typename
util
::
rm_ref
<
T
>::
type
>
>::
type
*
=
0
)
typename
std
::
enable_if
<
util
::
is_iterable
<
typename
util
::
rm_ref
<
T
>::
type
>::
value
>::
type
*
=
0
)
{
{
static
constexpr
bool
can_optimize
=
std
::
is_reference
<
T
>::
value
static
constexpr
bool
can_optimize
=
std
::
is_reference
<
T
>::
value
&&
!
std
::
is_const
<
T
>::
value
;
&&
!
std
::
is_const
<
T
>::
value
;
...
@@ -172,7 +176,11 @@ class any_tuple
...
@@ -172,7 +176,11 @@ class any_tuple
template
<
typename
T
>
template
<
typename
T
>
static
inline
any_tuple
view
(
T
&&
value
,
static
inline
any_tuple
view
(
T
&&
value
,
typename
util
::
disable_if
<
util
::
is_iterable
<
typename
util
::
rm_ref
<
T
>::
type
>
>::
type
*
=
0
)
typename
std
::
enable_if
<
util
::
is_iterable
<
typename
util
::
rm_ref
<
T
>::
type
>::
value
==
false
>::
type
*
=
0
)
{
{
typedef
typename
util
::
rm_ref
<
T
>::
type
vtype
;
typedef
typename
util
::
rm_ref
<
T
>::
type
vtype
;
typedef
typename
detail
::
implicit_conversions
<
vtype
>::
type
converted
;
typedef
typename
detail
::
implicit_conversions
<
vtype
>::
type
converted
;
...
...
cppa/behavior.hpp
View file @
332f9eee
...
@@ -34,12 +34,15 @@
...
@@ -34,12 +34,15 @@
#include <functional>
#include <functional>
#include <type_traits>
#include <type_traits>
#include "cppa/match_expr.hpp"
#include "cppa/partial_function.hpp"
#include "cppa/util/tbind.hpp"
#include "cppa/util/tbind.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/if_else.hpp"
#include "cppa/util/if_else.hpp"
#include "cppa/util/duration.hpp"
#include "cppa/util/duration.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/
partial_f
unction.hpp"
#include "cppa/
util/disj
unction.hpp"
namespace
cppa
{
namespace
cppa
{
...
@@ -58,18 +61,27 @@ class behavior
...
@@ -58,18 +61,27 @@ class behavior
behavior
()
=
default
;
behavior
()
=
default
;
behavior
(
behavior
&&
)
=
default
;
behavior
(
behavior
&&
)
=
default
;
behavior
&
operator
=
(
behavior
&&
)
=
default
;
inline
behavior
(
partial_function
&&
fun
)
:
m_fun
(
std
::
move
(
fun
))
inline
behavior
(
partial_function
&&
fun
)
:
m_fun
(
std
::
move
(
fun
))
{
{
}
}
template
<
typename
...
Cases
>
behavior
(
match_expr
<
Cases
...
>
const
&
me
)
:
m_fun
(
me
)
{
}
inline
behavior
(
util
::
duration
tout
,
std
::
function
<
void
()
>&&
handler
)
inline
behavior
(
util
::
duration
tout
,
std
::
function
<
void
()
>&&
handler
)
:
m_timeout
(
tout
),
m_timeout_handler
(
std
::
move
(
handler
))
:
m_timeout
(
tout
),
m_timeout_handler
(
std
::
move
(
handler
))
{
{
}
}
behavior
&
operator
=
(
behavior
&&
)
=
default
;
//behavior& operator=(partial_function&& pfun)
//{
// m_fun = std::move(pfun);
// return *this;
//}
inline
void
handle_timeout
()
const
inline
void
handle_timeout
()
const
{
{
m_timeout_handler
();
m_timeout_handler
();
...
@@ -80,31 +92,11 @@ class behavior
...
@@ -80,31 +92,11 @@ class behavior
return
m_timeout
;
return
m_timeout
;
}
}
inline
void
operator
()(
any_tuple
const
&
value
)
{
m_fun
(
value
);
}
inline
partial_function
&
get_partial_function
()
inline
partial_function
&
get_partial_function
()
{
{
return
m_fun
;
return
m_fun
;
}
}
inline
behavior
&
splice
(
behavior
&&
what
)
{
m_fun
.
splice
(
std
::
move
(
what
.
get_partial_function
()));
m_timeout
=
what
.
m_timeout
;
m_timeout_handler
=
std
::
move
(
what
.
m_timeout_handler
);
return
*
this
;
}
template
<
class
...
Args
>
inline
behavior
&
splice
(
partial_function
&&
arg0
,
Args
&&
...
args
)
{
m_fun
.
splice
(
std
::
move
(
arg0
));
return
splice
(
std
::
forward
<
Args
>
(
args
)...);
}
private:
private:
// terminates recursion
// terminates recursion
...
@@ -116,16 +108,69 @@ class behavior
...
@@ -116,16 +108,69 @@ class behavior
};
};
template
<
typename
...
Lhs
>
behavior
operator
,(
match_expr
<
Lhs
...
>
const
&
lhs
,
behavior
&&
rhs
)
{
rhs
.
get_partial_function
()
=
lhs
;
return
std
::
move
(
rhs
);
}
template
<
typename
Arg0
>
behavior
bhvr_collapse
(
Arg0
&&
arg
)
{
return
{
std
::
forward
<
Arg0
>
(
arg
)};
}
template
<
typename
Arg0
,
typename
Arg1
,
typename
...
Args
>
behavior
bhvr_collapse
(
Arg0
&&
arg0
,
Arg1
&&
arg1
,
Args
&&
...
args
)
{
return
bhvr_collapse
((
std
::
forward
<
Arg0
>
(
arg0
),
std
::
forward
<
Arg1
>
(
arg1
)),
std
::
forward
<
Args
>
(
args
)...);
}
template
<
typename
...
Args
>
typename
std
::
enable_if
<
util
::
disjunction
<
std
::
is_same
<
behavior
,
Args
>
...
>::
value
,
behavior
>::
type
match_expr_concat
(
Args
&&
...
args
)
{
return
bhvr_collapse
(
std
::
forward
<
Args
>
(
args
)...);
}
template
<
typename
...
Args
>
typename
std
::
enable_if
<
util
::
disjunction
<
std
::
is_same
<
behavior
,
typename
util
::
rm_ref
<
Args
>::
type
>
...
>::
value
==
false
,
partial_function
>::
type
match_expr_concat
(
Args
&&
...
args
)
{
return
mexpr_concat_convert
(
std
::
forward
<
Args
>
(
args
)...);
}
inline
partial_function
match_expr_concat
(
partial_function
&&
pfun
)
{
return
std
::
move
(
pfun
);
}
inline
behavior
match_expr_concat
(
behavior
&&
bhvr
)
{
return
std
::
move
(
bhvr
);
}
namespace
detail
{
namespace
detail
{
template
<
typename
...
Ts
>
template
<
typename
...
Ts
>
struct
select_bhvr
struct
select_bhvr
{
{
static
constexpr
bool
timed
=
static
constexpr
bool
timed
=
util
::
tl_exists
<
util
::
disjunction
<
std
::
is_same
<
behavior
,
Ts
>
...
>::
value
;
util
::
type_list
<
Ts
...
>
,
util
::
tbind
<
std
::
is_same
,
behavior
>::
type
>::
value
;
typedef
typename
util
::
if_else_c
<
timed
,
typedef
typename
util
::
if_else_c
<
timed
,
behavior
,
behavior
,
util
::
wrapped
<
partial_function
>
>::
type
util
::
wrapped
<
partial_function
>
>::
type
...
...
cppa/cppa.hpp
View file @
332f9eee
...
@@ -55,8 +55,6 @@
...
@@ -55,8 +55,6 @@
#include "cppa/event_based_actor.hpp"
#include "cppa/event_based_actor.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/enable_if.hpp"
#include "cppa/util/disable_if.hpp"
#include "cppa/detail/actor_count.hpp"
#include "cppa/detail/actor_count.hpp"
#include "cppa/detail/get_behavior.hpp"
#include "cppa/detail/get_behavior.hpp"
...
@@ -512,9 +510,11 @@ inline actor_ptr spawn(abstract_event_based_actor* what)
...
@@ -512,9 +510,11 @@ inline actor_ptr spawn(abstract_event_based_actor* what)
template
<
scheduling_hint
Hint
,
typename
F
,
typename
...
Args
>
template
<
scheduling_hint
Hint
,
typename
F
,
typename
...
Args
>
auto
//actor_ptr
auto
//actor_ptr
spawn
(
F
&&
what
,
Args
const
&
...
args
)
spawn
(
F
&&
what
,
Args
const
&
...
args
)
->
typename
util
::
disable_if_c
<
std
::
is_convertible
<
typename
util
::
rm_ref
<
F
>::
type
,
scheduled_actor
*>::
value
->
typename
std
::
enable_if
<
||
std
::
is_convertible
<
typename
util
::
rm_ref
<
F
>::
type
,
event_based_actor
*>::
value
,
!
std
::
is_convertible
<
typename
util
::
rm_ref
<
F
>::
type
,
scheduled_actor
*>::
value
actor_ptr
>::
type
&&
!
std
::
is_convertible
<
typename
util
::
rm_ref
<
F
>::
type
,
event_based_actor
*>::
value
,
actor_ptr
>::
type
{
{
typedef
typename
util
::
rm_ref
<
F
>::
type
ftype
;
typedef
typename
util
::
rm_ref
<
F
>::
type
ftype
;
std
::
integral_constant
<
bool
,
std
::
is_function
<
ftype
>::
value
>
is_fun
;
std
::
integral_constant
<
bool
,
std
::
is_function
<
ftype
>::
value
>
is_fun
;
...
@@ -529,9 +529,11 @@ spawn(F&& what, Args const&... args)
...
@@ -529,9 +529,11 @@ spawn(F&& what, Args const&... args)
template
<
typename
F
,
typename
...
Args
>
template
<
typename
F
,
typename
...
Args
>
auto
// actor_ptr
auto
// actor_ptr
spawn
(
F
&&
what
,
Args
const
&
...
args
)
spawn
(
F
&&
what
,
Args
const
&
...
args
)
->
typename
util
::
disable_if_c
<
std
::
is_convertible
<
typename
util
::
rm_ref
<
F
>::
type
,
scheduled_actor
*>::
value
->
typename
std
::
enable_if
<
||
std
::
is_convertible
<
typename
util
::
rm_ref
<
F
>::
type
,
event_based_actor
*>::
value
,
!
std
::
is_convertible
<
typename
util
::
rm_ref
<
F
>::
type
,
scheduled_actor
*>::
value
actor_ptr
>::
type
&&
!
std
::
is_convertible
<
typename
util
::
rm_ref
<
F
>::
type
,
event_based_actor
*>::
value
,
actor_ptr
>::
type
{
{
return
spawn
<
scheduled
>
(
std
::
forward
<
F
>
(
what
),
args
...);
return
spawn
<
scheduled
>
(
std
::
forward
<
F
>
(
what
),
args
...);
}
}
...
@@ -590,7 +592,10 @@ inline void send(self_type const&, Arg0 const& arg0, Args const&... args)
...
@@ -590,7 +592,10 @@ inline void send(self_type const&, Arg0 const& arg0, Args const&... args)
}
}
template
<
class
C
>
template
<
class
C
>
typename
util
::
enable_if
<
std
::
is_base_of
<
channel
,
C
>
,
intrusive_ptr
<
C
>&>::
type
typename
std
::
enable_if
<
std
::
is_base_of
<
channel
,
C
>::
value
,
intrusive_ptr
<
C
>&
>::
type
operator
<<
(
intrusive_ptr
<
C
>&
whom
,
any_tuple
const
&
what
)
operator
<<
(
intrusive_ptr
<
C
>&
whom
,
any_tuple
const
&
what
)
{
{
if
(
whom
)
whom
->
enqueue
(
self
,
what
);
if
(
whom
)
whom
->
enqueue
(
self
,
what
);
...
@@ -598,7 +603,10 @@ operator<<(intrusive_ptr<C>& whom, any_tuple const& what)
...
@@ -598,7 +603,10 @@ operator<<(intrusive_ptr<C>& whom, any_tuple const& what)
}
}
template
<
class
C
>
template
<
class
C
>
typename
util
::
enable_if
<
std
::
is_base_of
<
channel
,
C
>
,
intrusive_ptr
<
C
>>::
type
typename
std
::
enable_if
<
std
::
is_base_of
<
channel
,
C
>::
value
,
intrusive_ptr
<
C
>
>::
type
operator
<<
(
intrusive_ptr
<
C
>&&
whom
,
any_tuple
const
&
what
)
operator
<<
(
intrusive_ptr
<
C
>&&
whom
,
any_tuple
const
&
what
)
{
{
intrusive_ptr
<
C
>
tmp
(
std
::
move
(
whom
));
intrusive_ptr
<
C
>
tmp
(
std
::
move
(
whom
));
...
@@ -607,7 +615,10 @@ operator<<(intrusive_ptr<C>&& whom, any_tuple const& what)
...
@@ -607,7 +615,10 @@ operator<<(intrusive_ptr<C>&& whom, any_tuple const& what)
}
}
template
<
class
C
>
template
<
class
C
>
typename
util
::
enable_if
<
std
::
is_base_of
<
channel
,
C
>
,
intrusive_ptr
<
C
>&>::
type
typename
std
::
enable_if
<
std
::
is_base_of
<
channel
,
C
>::
value
,
intrusive_ptr
<
C
>&
>::
type
operator
<<
(
intrusive_ptr
<
C
>&
whom
,
any_tuple
&&
what
)
operator
<<
(
intrusive_ptr
<
C
>&
whom
,
any_tuple
&&
what
)
{
{
if
(
whom
)
whom
->
enqueue
(
self
,
std
::
move
(
what
));
if
(
whom
)
whom
->
enqueue
(
self
,
std
::
move
(
what
));
...
@@ -615,7 +626,10 @@ operator<<(intrusive_ptr<C>& whom, any_tuple&& what)
...
@@ -615,7 +626,10 @@ operator<<(intrusive_ptr<C>& whom, any_tuple&& what)
}
}
template
<
class
C
>
template
<
class
C
>
typename
util
::
enable_if
<
std
::
is_base_of
<
channel
,
C
>
,
intrusive_ptr
<
C
>>::
type
typename
std
::
enable_if
<
std
::
is_base_of
<
channel
,
C
>::
value
,
intrusive_ptr
<
C
>
>::
type
operator
<<
(
intrusive_ptr
<
C
>&&
whom
,
any_tuple
&&
what
)
operator
<<
(
intrusive_ptr
<
C
>&&
whom
,
any_tuple
&&
what
)
{
{
intrusive_ptr
<
C
>
tmp
(
std
::
move
(
whom
));
intrusive_ptr
<
C
>
tmp
(
std
::
move
(
whom
));
...
...
cppa/detail/default_uniform_type_info_impl.hpp
View file @
332f9eee
...
@@ -263,7 +263,7 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T
...
@@ -263,7 +263,7 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T
// pr.first = getter member const function pointer
// pr.first = getter member const function pointer
// pr.second = setter member function pointer
// pr.second = setter member function pointer
template
<
typename
GRes
,
typename
SRes
,
typename
SArg
,
class
C
,
typename
...
Args
>
template
<
typename
GRes
,
typename
SRes
,
typename
SArg
,
class
C
,
typename
...
Args
>
typename
util
::
enable_if
<
util
::
is_primitive
<
typename
util
::
rm_ref
<
GRes
>::
type
>
>::
type
typename
std
::
enable_if
<
util
::
is_primitive
<
typename
util
::
rm_ref
<
GRes
>::
type
>::
value
>::
type
push_back
(
const
std
::
pair
<
GRes
(
C
::*
)()
const
,
SRes
(
C
::*
)(
SArg
)
>&
pr
,
push_back
(
const
std
::
pair
<
GRes
(
C
::*
)()
const
,
SRes
(
C
::*
)(
SArg
)
>&
pr
,
Args
&&
...
args
)
Args
&&
...
args
)
{
{
...
@@ -273,7 +273,7 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T
...
@@ -273,7 +273,7 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T
}
}
template
<
typename
R
,
class
C
,
typename
...
Args
>
template
<
typename
R
,
class
C
,
typename
...
Args
>
typename
util
::
enable_if
<
util
::
is_primitive
<
R
>
>::
type
typename
std
::
enable_if
<
util
::
is_primitive
<
R
>::
value
>::
type
push_back
(
R
C
::*
mem_ptr
,
Args
&&
...
args
)
push_back
(
R
C
::*
mem_ptr
,
Args
&&
...
args
)
{
{
m_members
.
push_back
({
new
primitive_member
<
R
>
(),
mem_ptr
});
m_members
.
push_back
({
new
primitive_member
<
R
>
(),
mem_ptr
});
...
@@ -281,7 +281,7 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T
...
@@ -281,7 +281,7 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T
}
}
template
<
typename
R
,
class
C
,
typename
...
Args
>
template
<
typename
R
,
class
C
,
typename
...
Args
>
typename
util
::
enable_if
<
is_stl_compliant_list
<
R
>
>::
type
typename
std
::
enable_if
<
is_stl_compliant_list
<
R
>::
value
>::
type
push_back
(
R
C
::*
mem_ptr
,
Args
&&
...
args
)
push_back
(
R
C
::*
mem_ptr
,
Args
&&
...
args
)
{
{
m_members
.
push_back
({
new
list_member
<
R
>
(),
mem_ptr
});
m_members
.
push_back
({
new
list_member
<
R
>
(),
mem_ptr
});
...
@@ -289,7 +289,7 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T
...
@@ -289,7 +289,7 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T
}
}
template
<
typename
R
,
class
C
,
typename
...
Args
>
template
<
typename
R
,
class
C
,
typename
...
Args
>
typename
util
::
enable_if
<
is_stl_compliant_map
<
R
>
>::
type
typename
std
::
enable_if
<
is_stl_compliant_map
<
R
>::
value
>::
type
push_back
(
R
C
::*
mem_ptr
,
Args
&&
...
args
)
push_back
(
R
C
::*
mem_ptr
,
Args
&&
...
args
)
{
{
m_members
.
push_back
({
new
map_member
<
R
>
(),
mem_ptr
});
m_members
.
push_back
({
new
map_member
<
R
>
(),
mem_ptr
});
...
@@ -297,7 +297,7 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T
...
@@ -297,7 +297,7 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T
}
}
template
<
typename
R
,
class
C
,
typename
...
Args
>
template
<
typename
R
,
class
C
,
typename
...
Args
>
typename
util
::
enable_if
<
is_invalid
<
R
>
>::
type
typename
std
::
enable_if
<
is_invalid
<
R
>::
value
>::
type
push_back
(
R
C
::*
mem_ptr
,
Args
&&
...
args
)
push_back
(
R
C
::*
mem_ptr
,
Args
&&
...
args
)
{
{
static_assert
(
util
::
is_primitive
<
R
>::
value
,
static_assert
(
util
::
is_primitive
<
R
>::
value
,
...
@@ -306,25 +306,25 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T
...
@@ -306,25 +306,25 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T
}
}
template
<
typename
P
>
template
<
typename
P
>
void
init_
(
typename
util
::
enable_if
<
util
::
is_primitive
<
P
>
>::
type
*
=
0
)
void
init_
(
typename
std
::
enable_if
<
util
::
is_primitive
<
P
>::
value
>::
type
*
=
0
)
{
{
m_members
.
push_back
(
member
::
fake_member
(
new
primitive_member
<
P
>
()));
m_members
.
push_back
(
member
::
fake_member
(
new
primitive_member
<
P
>
()));
}
}
template
<
typename
Map
>
template
<
typename
Map
>
void
init_
(
typename
util
::
enable_if
<
is_stl_compliant_map
<
Map
>
>::
type
*
=
0
)
void
init_
(
typename
std
::
enable_if
<
is_stl_compliant_map
<
Map
>::
value
>::
type
*
=
0
)
{
{
m_members
.
push_back
(
member
::
fake_member
(
new
map_member
<
Map
>
));
m_members
.
push_back
(
member
::
fake_member
(
new
map_member
<
Map
>
));
}
}
template
<
typename
List
>
template
<
typename
List
>
void
init_
(
typename
util
::
enable_if
<
is_stl_compliant_list
<
List
>
>::
type
*
=
0
)
void
init_
(
typename
std
::
enable_if
<
is_stl_compliant_list
<
List
>::
value
>::
type
*
=
0
)
{
{
m_members
.
push_back
(
member
::
fake_member
(
new
list_member
<
List
>
));
m_members
.
push_back
(
member
::
fake_member
(
new
list_member
<
List
>
));
}
}
template
<
typename
X
>
template
<
typename
X
>
void
init_
(
typename
util
::
enable_if
<
is_invalid
<
X
>
>::
type
*
=
0
)
void
init_
(
typename
std
::
enable_if
<
is_invalid
<
X
>::
value
>::
type
*
=
0
)
{
{
// T is neither primitive nor a STL compliant list/map,
// T is neither primitive nor a STL compliant list/map,
// so it has to be an announced type
// so it has to be an announced type
...
...
cppa/detail/projection.hpp
View file @
332f9eee
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
#include "cppa/util/rm_option.hpp"
#include "cppa/util/rm_option.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/apply_args.hpp"
#include "cppa/util/apply_tuple.hpp"
#include "cppa/util/apply_tuple.hpp"
#include "cppa/util/left_or_right.hpp"
#include "cppa/util/left_or_right.hpp"
...
@@ -71,6 +72,9 @@ class projection
...
@@ -71,6 +72,9 @@ class projection
typedef
typename
tdata_from_type_list
<
ProjectionFuns
>::
type
fun_container
;
typedef
typename
tdata_from_type_list
<
ProjectionFuns
>::
type
fun_container
;
projection
()
=
default
;
projection
(
fun_container
&&
args
)
:
m_funs
(
std
::
move
(
args
))
{
}
projection
(
fun_container
const
&
args
)
:
m_funs
(
args
)
{
}
projection
(
fun_container
const
&
args
)
:
m_funs
(
args
)
{
}
...
@@ -170,6 +174,7 @@ class projection<util::type_list<> >
...
@@ -170,6 +174,7 @@ class projection<util::type_list<> >
fun
();
fun
();
return
true
;
return
true
;
}
}
};
};
template
<
class
ProjectionFuns
,
class
List
>
template
<
class
ProjectionFuns
,
class
List
>
...
...
cppa/
util/enable_if
.hpp
→
cppa/
detail/pseudo_tuple
.hpp
View file @
332f9eee
...
@@ -28,32 +28,64 @@
...
@@ -28,32 +28,64 @@
\******************************************************************************/
\******************************************************************************/
#ifndef
ENABLE_IF
_HPP
#ifndef
PSEUDO_TUPLE
_HPP
#define
ENABLE_IF
_HPP
#define
PSEUDO_TUPLE
_HPP
namespace
cppa
{
namespace
util
{
#include "cppa/util/at.hpp"
template
<
bool
Stmt
,
typename
T
=
void
>
namespace
cppa
{
namespace
detail
{
struct
enable_if_c
template
<
typename
...
T
>
struct
pseudo_tuple
{
{
typedef
void
*
ptr_type
;
typedef
void
const
*
const_ptr_type
;
ptr_type
data
[
sizeof
...(
T
)
>
0
?
sizeof
...(
T
)
:
1
];
inline
const_ptr_type
at
(
size_t
p
)
const
{
return
data
[
p
];
}
inline
ptr_type
mutable_at
(
size_t
p
)
{
return
const_cast
<
ptr_type
>
(
data
[
p
]);
}
inline
void
*&
operator
[](
size_t
p
)
{
return
data
[
p
];
}
};
};
template
<
typename
T
>
template
<
class
List
>
struct
enable_if_c
<
true
,
T
>
struct
pseudo_tuple_from_type_list
;
template
<
typename
...
Ts
>
struct
pseudo_tuple_from_type_list
<
util
::
type_list
<
Ts
...
>
>
{
{
typedef
T
type
;
typedef
pseudo_tuple
<
Ts
...
>
type
;
};
};
/**
}
}
// namespace cppa::detail
* @ingroup MetaProgramming
* @brief SFINAE trick to enable a template function based on its
namespace
cppa
{
* template parameters.
*/
template
<
size_t
N
,
typename
...
Tn
>
template
<
class
Trait
,
typename
T
=
void
>
typename
util
::
at
<
N
,
Tn
...
>::
type
const
&
get
(
detail
::
pseudo_tuple
<
Tn
...
>
const
&
tv
)
struct
enable_if
:
enable_if_c
<
Trait
::
value
,
T
>
{
{
};
static_assert
(
N
<
sizeof
...(
Tn
),
"N >= tv.size()"
);
return
*
reinterpret_cast
<
typename
util
::
at
<
N
,
Tn
...
>::
type
const
*>
(
tv
.
at
(
N
));
}
template
<
size_t
N
,
typename
...
Tn
>
typename
util
::
at
<
N
,
Tn
...
>::
type
&
get_ref
(
detail
::
pseudo_tuple
<
Tn
...
>&
tv
)
{
static_assert
(
N
<
sizeof
...(
Tn
),
"N >= tv.size()"
);
return
*
reinterpret_cast
<
typename
util
::
at
<
N
,
Tn
...
>::
type
*>
(
tv
.
mutable_at
(
N
));
}
}
}
// namespace cppa::util
}
// namespace cppa
#endif //
ENABLE_IF
_HPP
#endif //
PSEUDO_TUPLE
_HPP
cppa/detail/receive_loop_helper.hpp
View file @
332f9eee
...
@@ -66,18 +66,14 @@ struct receive_while_helper
...
@@ -66,18 +66,14 @@ struct receive_while_helper
while
(
m_stmt
())
sptr
->
dequeue
(
fun
);
while
(
m_stmt
())
sptr
->
dequeue
(
fun
);
}
}
void
operator
()(
behavior
&&
bhvr
)
template
<
typename
Arg0
,
typename
...
Args
>
void
operator
()(
Arg0
&&
arg0
,
Args
&&
...
args
)
{
{
behavior
tmp
{
std
::
move
(
bhvr
)};
auto
tmp
=
match_expr_concat
(
std
::
forward
<
Arg0
>
(
arg0
),
std
::
forward
<
Args
>
(
args
)...);
(
*
this
)(
tmp
);
(
*
this
)(
tmp
);
}
}
template
<
typename
...
Args
>
void
operator
()(
partial_function
&&
arg0
,
Args
&&
...
args
)
{
typename
select_bhvr
<
Args
...
>::
type
tmp
;
(
*
this
)(
tmp
.
splice
(
std
::
move
(
arg0
),
std
::
forward
<
Args
>
(
args
)...));
}
};
};
...
@@ -104,19 +100,14 @@ class receive_for_helper
...
@@ -104,19 +100,14 @@ class receive_for_helper
for
(
;
begin
!=
end
;
++
begin
)
sptr
->
dequeue
(
fun
);
for
(
;
begin
!=
end
;
++
begin
)
sptr
->
dequeue
(
fun
);
}
}
void
operator
()(
behavior
&&
bhvr
)
template
<
typename
Arg0
,
typename
...
Args
>
void
operator
()(
Arg0
&&
arg0
,
Args
&&
...
args
)
{
{
behavior
tmp
{
std
::
move
(
bhvr
)};
auto
tmp
=
match_expr_concat
(
std
::
forward
<
Arg0
>
(
arg0
),
std
::
forward
<
Args
>
(
args
)...);
(
*
this
)(
tmp
);
(
*
this
)(
tmp
);
}
}
template
<
typename
...
Args
>
void
operator
()(
partial_function
&&
arg0
,
Args
&&
...
args
)
{
typename
select_bhvr
<
Args
...
>::
type
tmp
;
(
*
this
)(
tmp
.
splice
(
std
::
move
(
arg0
),
std
::
forward
<
Args
>
(
args
)...));
}
};
};
class
do_receive_helper
class
do_receive_helper
...
@@ -126,14 +117,10 @@ class do_receive_helper
...
@@ -126,14 +117,10 @@ class do_receive_helper
public:
public:
do_receive_helper
(
behavior
&&
bhvr
)
:
m_bhvr
(
std
::
move
(
bhvr
))
template
<
typename
...
Args
>
{
do_receive_helper
(
Args
&&
...
args
)
}
:
m_bhvr
(
match_expr_concat
(
std
::
forward
<
Args
>
(
args
)...))
template
<
typename
Arg0
,
typename
...
Args
>
do_receive_helper
(
Arg0
&&
arg0
,
Args
&&
...
args
)
{
{
m_bhvr
.
splice
(
std
::
forward
<
Arg0
>
(
arg0
),
std
::
forward
<
Args
>
(
args
)...);
}
}
do_receive_helper
(
do_receive_helper
&&
)
=
default
;
do_receive_helper
(
do_receive_helper
&&
)
=
default
;
...
...
cppa/detail/tdata.hpp
View file @
332f9eee
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
#include <typeinfo>
#include <typeinfo>
#include <functional>
#include <functional>
#include <type_traits>
#include "cppa/get.hpp"
#include "cppa/get.hpp"
#include "cppa/option.hpp"
#include "cppa/option.hpp"
...
@@ -40,8 +41,6 @@
...
@@ -40,8 +41,6 @@
#include "cppa/util/at.hpp"
#include "cppa/util/at.hpp"
#include "cppa/util/wrapped.hpp"
#include "cppa/util/wrapped.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/enable_if.hpp"
#include "cppa/util/disable_if.hpp"
#include "cppa/util/arg_match_t.hpp"
#include "cppa/util/arg_match_t.hpp"
#include "cppa/detail/boxed.hpp"
#include "cppa/detail/boxed.hpp"
...
@@ -151,7 +150,8 @@ struct tdata<>
...
@@ -151,7 +150,8 @@ struct tdata<>
tdata
(
Args
&&
...)
tdata
(
Args
&&
...)
{
{
typedef
util
::
type_list
<
typename
util
::
rm_ref
<
Args
>::
type
...
>
incoming
;
typedef
util
::
type_list
<
typename
util
::
rm_ref
<
Args
>::
type
...
>
incoming
;
static_assert
(
util
::
tl_forall
<
incoming
,
boxed_or_void
>::
value
,
typedef
typename
util
::
tl_filter_not_type
<
incoming
,
tdata
>::
type
iargs
;
static_assert
(
util
::
tl_forall
<
iargs
,
boxed_or_void
>::
value
,
"Additional unboxed arguments provided"
);
"Additional unboxed arguments provided"
);
}
}
...
@@ -163,10 +163,6 @@ struct tdata<>
...
@@ -163,10 +163,6 @@ struct tdata<>
inline
const_iterator
end
()
const
{
return
{
this
};
}
inline
const_iterator
end
()
const
{
return
{
this
};
}
inline
const_iterator
cend
()
const
{
return
{
this
};
}
inline
const_iterator
cend
()
const
{
return
{
this
};
}
inline
tdata
(
tdata
&
)
{
}
inline
tdata
(
tdata
&&
)
{
}
inline
tdata
(
tdata
const
&
)
{
}
inline
size_t
size
()
const
{
return
num_elements
;
}
inline
size_t
size
()
const
{
return
num_elements
;
}
tdata
<>&
tail
()
{
return
*
this
;
}
tdata
<>&
tail
()
{
return
*
this
;
}
...
@@ -276,15 +272,22 @@ struct tdata<Head, Tail...> : tdata<Tail...>
...
@@ -276,15 +272,22 @@ struct tdata<Head, Tail...> : tdata<Tail...>
//tdata(Head const& v0, Tail const&... vals) : super(vals...), head(v0) { }
//tdata(Head const& v0, Tail const&... vals) : super(vals...), head(v0) { }
template
<
typename
Arg0
,
typename
...
Args
>
tdata
(
Head
arg
)
:
super
(),
head
(
std
::
move
(
arg
))
{
}
tdata
(
Arg0
&&
arg0
,
Args
&&
...
args
)
:
super
(
std
::
forward
<
Args
>
(
args
)...)
template
<
typename
Arg0
,
typename
Arg1
,
typename
...
Args
>
tdata
(
Arg0
&&
arg0
,
Arg1
&&
arg1
,
Args
&&
...
args
)
:
super
(
std
::
forward
<
Arg1
>
(
arg1
),
std
::
forward
<
Args
>
(
args
)...)
,
head
(
td_filter
<
Head
>
(
std
::
forward
<
Arg0
>
(
arg0
)))
,
head
(
td_filter
<
Head
>
(
std
::
forward
<
Arg0
>
(
arg0
)))
{
{
}
}
tdata
(
tdata
const
&
)
=
default
;
tdata
(
tdata
const
&
)
=
default
;
tdata
(
tdata
&&
other
)
:
super
(
std
::
move
(
other
.
tail
())),
head
(
std
::
move
(
other
.
head
))
{
}
// allow (partial) initialization from a different tdata
// allow (partial) initialization from a different tdata
template
<
typename
...
Y
>
template
<
typename
...
Y
>
...
...
cppa/event_based_actor_base.hpp
View file @
332f9eee
...
@@ -62,18 +62,12 @@ class event_based_actor_base : public abstract_event_based_actor
...
@@ -62,18 +62,12 @@ class event_based_actor_base : public abstract_event_based_actor
}
}
/** @brief Sets the actor's behavior. */
/** @brief Sets the actor's behavior. */
template
<
typename
...
Args
>
template
<
typename
Arg0
,
typename
...
Args
>
void
become
(
partial_function
&&
arg0
,
Args
&&
...
args
)
void
become
(
Arg0
&&
arg0
,
Args
&&
...
args
)
{
{
auto
ptr
=
new
behavior
;
behavior
tmp
=
match_expr_concat
(
std
::
forward
<
Arg0
>
(
arg0
),
ptr
->
splice
(
std
::
move
(
arg0
),
std
::
forward
<
Args
>
(
args
)...);
std
::
forward
<
Args
>
(
args
)...);
d_this
()
->
do_become
(
ptr
,
true
);
d_this
()
->
do_become
(
new
behavior
(
std
::
move
(
tmp
)),
true
);
}
/** @brief Sets the actor's behavior to @p bhvr. */
inline
void
become
(
behavior
&&
bhvr
)
{
d_this
()
->
do_become
(
new
behavior
(
std
::
move
(
bhvr
)),
true
);
}
}
};
};
...
...
cppa/fsm_actor.hpp
View file @
332f9eee
...
@@ -34,7 +34,6 @@
...
@@ -34,7 +34,6 @@
#include <type_traits>
#include <type_traits>
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/enable_if.hpp"
#include "cppa/event_based_actor.hpp"
#include "cppa/event_based_actor.hpp"
namespace
cppa
{
namespace
cppa
{
...
...
cppa/get.hpp
View file @
332f9eee
...
@@ -38,10 +38,13 @@
...
@@ -38,10 +38,13 @@
namespace
cppa
{
namespace
cppa
{
// forward declaration of detail::tdata
// forward declaration of details
namespace
detail
{
template
<
typename
...
>
class
tdata
;
}
namespace
detail
{
template
<
typename
...
>
class
tdata
;
template
<
typename
...
>
struct
pseudo_tuple
;
}
// forward declaration of tuple
// forward declaration of
cow_
tuple
template
<
typename
...
>
class
cow_tuple
;
template
<
typename
...
>
class
cow_tuple
;
// forward declaration of get(detail::tdata<...> const&)
// forward declaration of get(detail::tdata<...> const&)
...
@@ -52,6 +55,10 @@ typename util::at<N, Tn...>::type const& get(detail::tdata<Tn...> const&);
...
@@ -52,6 +55,10 @@ typename util::at<N, Tn...>::type const& get(detail::tdata<Tn...> const&);
template
<
size_t
N
,
typename
...
Tn
>
template
<
size_t
N
,
typename
...
Tn
>
typename
util
::
at
<
N
,
Tn
...
>::
type
const
&
get
(
cow_tuple
<
Tn
...
>
const
&
);
typename
util
::
at
<
N
,
Tn
...
>::
type
const
&
get
(
cow_tuple
<
Tn
...
>
const
&
);
// forward declarations of get(detail::pseudo_tuple<...>&)
template
<
size_t
N
,
typename
...
Tn
>
typename
util
::
at
<
N
,
Tn
...
>::
type
const
&
get
(
detail
::
pseudo_tuple
<
Tn
...
>
const
&
tv
);
// forward declarations of get_ref(detail::tdata<...>&)
// forward declarations of get_ref(detail::tdata<...>&)
template
<
size_t
N
,
typename
...
Tn
>
template
<
size_t
N
,
typename
...
Tn
>
typename
util
::
at
<
N
,
Tn
...
>::
type
&
get_ref
(
detail
::
tdata
<
Tn
...
>&
);
typename
util
::
at
<
N
,
Tn
...
>::
type
&
get_ref
(
detail
::
tdata
<
Tn
...
>&
);
...
@@ -60,6 +67,10 @@ typename util::at<N, Tn...>::type& get_ref(detail::tdata<Tn...>&);
...
@@ -60,6 +67,10 @@ typename util::at<N, Tn...>::type& get_ref(detail::tdata<Tn...>&);
template
<
size_t
N
,
typename
...
Tn
>
template
<
size_t
N
,
typename
...
Tn
>
typename
util
::
at
<
N
,
Tn
...
>::
type
&
get_ref
(
cow_tuple
<
Tn
...
>&
);
typename
util
::
at
<
N
,
Tn
...
>::
type
&
get_ref
(
cow_tuple
<
Tn
...
>&
);
// forward declarations of get_ref(detail::pseudo_tuple<...>&)
template
<
size_t
N
,
typename
...
Tn
>
typename
util
::
at
<
N
,
Tn
...
>::
type
&
get_ref
(
detail
::
pseudo_tuple
<
Tn
...
>&
tv
);
// support container-like access for type lists containing tokens
// support container-like access for type lists containing tokens
template
<
size_t
N
,
typename
...
Ts
>
template
<
size_t
N
,
typename
...
Ts
>
typename
util
::
at
<
N
,
Ts
...
>::
type
get
(
util
::
type_list
<
Ts
...
>
const
&
)
typename
util
::
at
<
N
,
Ts
...
>::
type
get
(
util
::
type_list
<
Ts
...
>
const
&
)
...
...
cppa/guard_expr.hpp
View file @
332f9eee
...
@@ -41,7 +41,6 @@
...
@@ -41,7 +41,6 @@
#include "cppa/util/at.hpp"
#include "cppa/util/at.hpp"
#include "cppa/util/void_type.hpp"
#include "cppa/util/void_type.hpp"
#include "cppa/util/enable_if.hpp"
#include "cppa/util/apply_tuple.hpp"
#include "cppa/util/apply_tuple.hpp"
#include "cppa/detail/tdata.hpp"
#include "cppa/detail/tdata.hpp"
...
@@ -427,7 +426,7 @@ template<operator_id OP, typename T1, typename T2>
...
@@ -427,7 +426,7 @@ template<operator_id OP, typename T1, typename T2>
guard_expr
<
OP
,
typename
detail
::
strip_and_convert
<
T1
>::
type
,
guard_expr
<
OP
,
typename
detail
::
strip_and_convert
<
T1
>::
type
,
typename
detail
::
strip_and_convert
<
T2
>::
type
>
typename
detail
::
strip_and_convert
<
T2
>::
type
>
ge_concatenate
(
T1
first
,
T2
second
,
ge_concatenate
(
T1
first
,
T2
second
,
typename
util
::
enable_if_c
<
typename
std
::
enable_if
<
is_ge_type
<
T1
>::
value
||
is_ge_type
<
T2
>::
value
is_ge_type
<
T1
>::
value
||
is_ge_type
<
T2
>::
value
>::
type
*
=
0
)
>::
type
*
=
0
)
{
{
...
...
cppa/intrusive_ptr.hpp
View file @
332f9eee
...
@@ -36,7 +36,6 @@
...
@@ -36,7 +36,6 @@
#include <stdexcept>
#include <stdexcept>
#include <type_traits>
#include <type_traits>
#include "cppa/util/enable_if.hpp"
#include "cppa/util/comparable.hpp"
#include "cppa/util/comparable.hpp"
namespace
cppa
{
namespace
cppa
{
...
...
cppa/match.hpp
View file @
332f9eee
...
@@ -43,12 +43,16 @@ struct match_helper
...
@@ -43,12 +43,16 @@ struct match_helper
any_tuple
tup
;
any_tuple
tup
;
match_helper
(
any_tuple
&&
t
)
:
tup
(
std
::
move
(
t
))
{
}
match_helper
(
any_tuple
&&
t
)
:
tup
(
std
::
move
(
t
))
{
}
match_helper
(
match_helper
&&
)
=
default
;
match_helper
(
match_helper
&&
)
=
default
;
template
<
class
...
Args
>
void
operator
()(
partial_function
&&
arg
)
void
operator
()(
partial_function
&&
pf
,
Args
&&
...
args
)
{
{
partial_function
tmp
;
partial_function
tmp
{
std
::
move
(
arg
)};
tmp
.
splice
(
std
::
move
(
pf
),
std
::
forward
<
Args
>
(
args
)...);
tmp
(
tup
);
tmp
(
std
::
move
(
tup
));
}
template
<
class
Arg0
,
class
...
Args
>
void
operator
()(
Arg0
&&
arg0
,
Args
&&
...
args
)
{
(
*
this
)(
mexpr_concat_convert
(
std
::
forward
<
Arg0
>
(
arg0
),
std
::
forward
<
Args
>
(
args
)...));
}
}
};
};
...
@@ -61,16 +65,20 @@ struct match_each_helper
...
@@ -61,16 +65,20 @@ struct match_each_helper
Iterator
e
;
Iterator
e
;
match_each_helper
(
Iterator
first
,
Iterator
last
)
:
i
(
first
),
e
(
last
)
{
}
match_each_helper
(
Iterator
first
,
Iterator
last
)
:
i
(
first
),
e
(
last
)
{
}
match_each_helper
(
match_each_helper
&&
)
=
default
;
match_each_helper
(
match_each_helper
&&
)
=
default
;
template
<
typename
...
Args
>
void
operator
()(
partial_function
&&
arg
)
void
operator
()(
partial_function
&&
arg0
,
Args
&&
...
args
)
{
{
partial_function
tmp
;
partial_function
tmp
{
std
::
move
(
arg
)};
tmp
.
splice
(
std
::
move
(
arg0
),
std
::
forward
<
Args
>
(
args
)...);
for
(;
i
!=
e
;
++
i
)
for
(;
i
!=
e
;
++
i
)
{
{
tmp
(
any_tuple
::
view
(
*
i
));
tmp
(
any_tuple
::
view
(
*
i
));
}
}
}
}
template
<
class
Arg0
,
class
...
Args
>
void
operator
()(
Arg0
&&
arg0
,
Args
&&
...
args
)
{
(
*
this
)(
mexpr_concat_convert
(
std
::
forward
<
Arg0
>
(
arg0
),
std
::
forward
<
Args
>
(
args
)...));
}
};
};
template
<
class
Container
>
template
<
class
Container
>
...
@@ -81,16 +89,20 @@ struct copying_match_each_helper
...
@@ -81,16 +89,20 @@ struct copying_match_each_helper
Container
vec
;
Container
vec
;
copying_match_each_helper
(
Container
tmp
)
:
vec
(
std
::
move
(
tmp
))
{
}
copying_match_each_helper
(
Container
tmp
)
:
vec
(
std
::
move
(
tmp
))
{
}
copying_match_each_helper
(
copying_match_each_helper
&&
)
=
default
;
copying_match_each_helper
(
copying_match_each_helper
&&
)
=
default
;
template
<
typename
...
Args
>
void
operator
()(
partial_function
&&
arg
)
void
operator
()(
partial_function
&&
arg0
,
Args
&&
...
args
)
{
{
partial_function
tmp
;
partial_function
tmp
{
std
::
move
(
arg
)};
tmp
.
splice
(
std
::
move
(
arg0
),
std
::
forward
<
Args
>
(
args
)...);
for
(
auto
&
i
:
vec
)
for
(
auto
&
i
:
vec
)
{
{
tmp
(
any_tuple
::
view
(
i
));
tmp
(
any_tuple
::
view
(
i
));
}
}
}
}
template
<
class
Arg0
,
class
...
Args
>
void
operator
()(
Arg0
&&
arg0
,
Args
&&
...
args
)
{
(
*
this
)(
mexpr_concat_convert
(
std
::
forward
<
Arg0
>
(
arg0
),
std
::
forward
<
Args
>
(
args
)...));
}
};
};
template
<
typename
Iterator
,
typename
Projection
>
template
<
typename
Iterator
,
typename
Projection
>
...
@@ -107,16 +119,20 @@ struct pmatch_each_helper
...
@@ -107,16 +119,20 @@ struct pmatch_each_helper
:
i
(
first
),
e
(
last
),
p
(
std
::
forward
<
PJ
>
(
proj
))
:
i
(
first
),
e
(
last
),
p
(
std
::
forward
<
PJ
>
(
proj
))
{
{
}
}
template
<
typename
...
Args
>
void
operator
()(
partial_function
&&
arg
)
void
operator
()(
partial_function
&&
arg0
,
Args
&&
...
args
)
{
{
partial_function
tmp
;
partial_function
tmp
{
std
::
move
(
arg
)};
tmp
.
splice
(
std
::
move
(
arg0
),
std
::
forward
<
Args
>
(
args
)...);
for
(;
i
!=
e
;
++
i
)
for
(;
i
!=
e
;
++
i
)
{
{
tmp
(
any_tuple
::
view
(
p
(
*
i
)));
tmp
(
any_tuple
::
view
(
p
(
*
i
)));
}
}
}
}
template
<
class
Arg0
,
class
...
Args
>
void
operator
()(
Arg0
&&
arg0
,
Args
&&
...
args
)
{
(
*
this
)(
mexpr_concat_convert
(
std
::
forward
<
Arg0
>
(
arg0
),
std
::
forward
<
Args
>
(
args
)...));
}
};
};
}
}
// namespace cppa::detail
}
}
// namespace cppa::detail
...
...
cppa/match_expr.hpp
0 → 100644
View file @
332f9eee
This diff is collapsed.
Click to expand it.
cppa/on.hpp
View file @
332f9eee
This diff is collapsed.
Click to expand it.
cppa/partial_function.hpp
View file @
332f9eee
...
@@ -55,55 +55,50 @@ class partial_function
...
@@ -55,55 +55,50 @@ class partial_function
public:
public:
typedef
std
::
unique_ptr
<
detail
::
invokable
>
invokable_ptr
;
struct
impl
{
partial_function
()
=
default
;
virtual
~
impl
()
;
partial_function
(
partial_function
&&
other
)
;
virtual
bool
invoke
(
any_tuple
&
)
=
0
;
partial_function
&
operator
=
(
partial_function
&&
other
)
;
virtual
bool
invoke
(
any_tuple
const
&
)
=
0
;
virtual
bool
defined_at
(
any_tuple
const
&
)
=
0
;
partial_function
(
invokable_ptr
&&
ptr
)
;
}
;
bool
defined_at
(
any_tuple
const
&
value
)
;
typedef
std
::
unique_ptr
<
impl
>
impl_ptr
;
bool
operator
()(
any_tuple
value
);
partial_function
()
=
default
;
partial_function
(
partial_function
&&
)
=
default
;
partial_function
&
operator
=
(
partial_function
&&
)
=
default
;
detail
::
invokable
const
*
definition_at
(
any_tuple
value
);
partial_function
(
impl_ptr
&&
ptr
);
template
<
class
...
Args
>
inline
bool
defined_at
(
any_tuple
const
&
value
)
partial_function
&
splice
(
partial_function
&&
arg0
,
Args
&&
...
args
)
{
{
m_funs
.
splice_after
(
m_funs
.
before_end
(),
std
::
move
(
arg0
.
m_funs
));
return
((
m_impl
)
&&
m_impl
->
defined_at
(
value
));
arg0
.
m_cache
.
clear
();
return
splice
(
std
::
forward
<
Args
>
(
args
)...);
}
}
private:
inline
bool
operator
()(
any_tuple
&
value
)
{
return
((
m_impl
)
&&
m_impl
->
invoke
(
value
));
}
// terminates recursion
inline
bool
operator
()(
any_tuple
const
&
value
)
inline
partial_function
&
splice
()
{
{
m_cache
.
clear
();
return
((
m_impl
)
&&
m_impl
->
invoke
(
value
));
return
*
this
;
}
}
typedef
std
::
vector
<
detail
::
invokable
*>
cache_entry
;
inline
bool
operator
()(
any_tuple
&&
value
)
typedef
std
::
pair
<
void
const
*
,
cache_entry
>
cache_element
;
{
any_tuple
cpy
{
std
::
move
(
value
)};
return
(
*
this
)(
cpy
);
}
intrusive
::
singly_linked_list
<
detail
::
invokable
>
m_funs
;
private:
std
::
vector
<
cache_element
>
m_cache
;
cache_element
m_dummy
;
// binary search dummy
cache_entry
&
get_cache_entry
(
any_tuple
const
&
value
)
;
impl_ptr
m_impl
;
};
};
inline
partial_function
operator
,(
partial_function
&&
lhs
,
//behavior operator,(partial_function&& lhs, behavior&& rhs);
partial_function
&&
rhs
)
{
return
std
::
move
(
lhs
.
splice
(
std
::
move
(
rhs
)));
}
behavior
operator
,(
partial_function
&&
lhs
,
behavior
&&
rhs
);
}
// namespace cppa
}
// namespace cppa
...
...
cppa/primitive_variant.hpp
View file @
332f9eee
...
@@ -39,8 +39,6 @@
...
@@ -39,8 +39,6 @@
#include "cppa/primitive_type.hpp"
#include "cppa/primitive_type.hpp"
#include "cppa/util/pt_token.hpp"
#include "cppa/util/pt_token.hpp"
#include "cppa/util/enable_if.hpp"
#include "cppa/util/disable_if.hpp"
#include "cppa/util/pt_dispatch.hpp"
#include "cppa/util/pt_dispatch.hpp"
#include "cppa/util/is_primitive.hpp"
#include "cppa/util/is_primitive.hpp"
...
@@ -51,11 +49,11 @@ namespace cppa { namespace detail {
...
@@ -51,11 +49,11 @@ namespace cppa { namespace detail {
template
<
primitive_type
FT
,
class
T
,
class
V
>
template
<
primitive_type
FT
,
class
T
,
class
V
>
void
ptv_set
(
primitive_type
&
lhs_type
,
T
&
lhs
,
V
&&
rhs
,
void
ptv_set
(
primitive_type
&
lhs_type
,
T
&
lhs
,
V
&&
rhs
,
typename
util
::
disable_if
<
std
::
is_arithmetic
<
T
>
>::
type
*
=
0
);
typename
std
::
enable_if
<!
std
::
is_arithmetic
<
T
>::
value
>::
type
*
=
0
);
template
<
primitive_type
FT
,
class
T
,
class
V
>
template
<
primitive_type
FT
,
class
T
,
class
V
>
void
ptv_set
(
primitive_type
&
lhs_type
,
T
&
lhs
,
V
&&
rhs
,
void
ptv_set
(
primitive_type
&
lhs_type
,
T
&
lhs
,
V
&&
rhs
,
typename
util
::
enable_if
<
std
::
is_arithmetic
<
T
>
,
int
>::
type
*
=
0
);
typename
std
::
enable_if
<
std
::
is_arithmetic
<
T
>::
value
,
int
>::
type
*
=
0
);
}
}
// namespace cppa::detail
}
}
// namespace cppa::detail
...
@@ -363,7 +361,7 @@ bool operator!=(primitive_variant const& lhs, primitive_variant const& rhs)
...
@@ -363,7 +361,7 @@ bool operator!=(primitive_variant const& lhs, primitive_variant const& rhs)
}
}
template
<
typename
T
>
template
<
typename
T
>
typename
util
::
enable_if
<
util
::
is_primitive
<
T
>
,
bool
>::
type
typename
std
::
enable_if
<
util
::
is_primitive
<
T
>::
value
,
bool
>::
type
operator
==
(
T
const
&
lhs
,
primitive_variant
const
&
rhs
)
operator
==
(
T
const
&
lhs
,
primitive_variant
const
&
rhs
)
{
{
static
constexpr
primitive_type
ptype
=
detail
::
type_to_ptype
<
T
>::
ptype
;
static
constexpr
primitive_type
ptype
=
detail
::
type_to_ptype
<
T
>::
ptype
;
...
@@ -372,21 +370,21 @@ operator==(T const& lhs, primitive_variant const& rhs)
...
@@ -372,21 +370,21 @@ operator==(T const& lhs, primitive_variant const& rhs)
}
}
template
<
typename
T
>
template
<
typename
T
>
typename
util
::
enable_if
<
util
::
is_primitive
<
T
>
,
bool
>::
type
typename
std
::
enable_if
<
util
::
is_primitive
<
T
>::
value
,
bool
>::
type
operator
==
(
primitive_variant
const
&
lhs
,
T
const
&
rhs
)
operator
==
(
primitive_variant
const
&
lhs
,
T
const
&
rhs
)
{
{
return
(
rhs
==
lhs
);
return
(
rhs
==
lhs
);
}
}
template
<
typename
T
>
template
<
typename
T
>
typename
util
::
enable_if
<
util
::
is_primitive
<
T
>
,
bool
>::
type
typename
std
::
enable_if
<
util
::
is_primitive
<
T
>::
value
,
bool
>::
type
operator
!=
(
primitive_variant
const
&
lhs
,
T
const
&
rhs
)
operator
!=
(
primitive_variant
const
&
lhs
,
T
const
&
rhs
)
{
{
return
!
(
lhs
==
rhs
);
return
!
(
lhs
==
rhs
);
}
}
template
<
typename
T
>
template
<
typename
T
>
typename
util
::
enable_if
<
util
::
is_primitive
<
T
>
,
bool
>::
type
typename
std
::
enable_if
<
util
::
is_primitive
<
T
>::
value
,
bool
>::
type
operator
!=
(
T
const
&
lhs
,
primitive_variant
const
&
rhs
)
operator
!=
(
T
const
&
lhs
,
primitive_variant
const
&
rhs
)
{
{
return
!
(
lhs
==
rhs
);
return
!
(
lhs
==
rhs
);
...
@@ -398,7 +396,7 @@ namespace cppa { namespace detail {
...
@@ -398,7 +396,7 @@ namespace cppa { namespace detail {
template
<
primitive_type
FT
,
class
T
,
class
V
>
template
<
primitive_type
FT
,
class
T
,
class
V
>
void
ptv_set
(
primitive_type
&
lhs_type
,
T
&
lhs
,
V
&&
rhs
,
void
ptv_set
(
primitive_type
&
lhs_type
,
T
&
lhs
,
V
&&
rhs
,
typename
util
::
disable_if
<
std
::
is_arithmetic
<
T
>
>::
type
*
)
typename
std
::
enable_if
<!
std
::
is_arithmetic
<
T
>::
value
>::
type
*
)
{
{
if
(
FT
==
lhs_type
)
if
(
FT
==
lhs_type
)
{
{
...
@@ -413,7 +411,7 @@ void ptv_set(primitive_type& lhs_type, T& lhs, V&& rhs,
...
@@ -413,7 +411,7 @@ void ptv_set(primitive_type& lhs_type, T& lhs, V&& rhs,
template
<
primitive_type
FT
,
class
T
,
class
V
>
template
<
primitive_type
FT
,
class
T
,
class
V
>
void
ptv_set
(
primitive_type
&
lhs_type
,
T
&
lhs
,
V
&&
rhs
,
void
ptv_set
(
primitive_type
&
lhs_type
,
T
&
lhs
,
V
&&
rhs
,
typename
util
::
enable_if
<
std
::
is_arithmetic
<
T
>
,
int
>::
type
*
)
typename
std
::
enable_if
<
std
::
is_arithmetic
<
T
>::
value
,
int
>::
type
*
)
{
{
// don't call a constructor for arithmetic types
// don't call a constructor for arithmetic types
lhs
=
rhs
;
lhs
=
rhs
;
...
...
cppa/receive.hpp
View file @
332f9eee
...
@@ -121,36 +121,26 @@ inline void receive(behavior& bhvr) { self->dequeue(bhvr); }
...
@@ -121,36 +121,26 @@ inline void receive(behavior& bhvr) { self->dequeue(bhvr); }
inline
void
receive
(
partial_function
&
fun
)
{
self
->
dequeue
(
fun
);
}
inline
void
receive
(
partial_function
&
fun
)
{
self
->
dequeue
(
fun
);
}
inline
void
receive
(
behavior
&&
arg0
)
template
<
typename
Arg0
,
typename
...
Args
>
void
receive
(
Arg0
&&
arg0
,
Args
&&
...
args
)
{
{
behavior
tmp
{
std
::
move
(
arg0
)};
auto
tmp
=
match_expr_concat
(
std
::
forward
<
Arg0
>
(
arg0
),
std
::
forward
<
Args
>
(
args
)...);
receive
(
tmp
);
receive
(
tmp
);
}
}
template
<
typename
...
Args
>
void
receive
(
partial_function
&&
arg0
,
Args
&&
...
args
)
{
typename
detail
::
select_bhvr
<
Args
...
>::
type
tmp
;
receive
(
tmp
.
splice
(
std
::
move
(
arg0
),
std
::
forward
<
Args
>
(
args
)...));
}
void
receive_loop
(
behavior
&
rules
);
void
receive_loop
(
behavior
&
rules
);
void
receive_loop
(
partial_function
&
rules
);
void
receive_loop
(
partial_function
&
rules
);
inline
void
receive_loop
(
behavior
&&
arg0
)
template
<
typename
Arg0
,
typename
...
Args
>
void
receive_loop
(
Arg0
&&
arg0
,
Args
&&
...
args
)
{
{
behavior
tmp
{
std
::
move
(
arg0
)};
auto
tmp
=
match_expr_concat
(
std
::
forward
<
Arg0
>
(
arg0
),
std
::
forward
<
Args
>
(
args
)...);
receive_loop
(
tmp
);
receive_loop
(
tmp
);
}
}
template
<
typename
...
Args
>
void
receive_loop
(
partial_function
&&
arg0
,
Args
&&
...
args
)
{
typename
detail
::
select_bhvr
<
Args
...
>::
type
tmp
;
receive_loop
(
tmp
.
splice
(
std
::
move
(
arg0
),
std
::
forward
<
Args
>
(
args
)...));
}
template
<
typename
T
>
template
<
typename
T
>
detail
::
receive_for_helper
<
T
>
receive_for
(
T
&
begin
,
T
const
&
end
)
detail
::
receive_for_helper
<
T
>
receive_for
(
T
&
begin
,
T
const
&
end
)
{
{
...
...
cppa/util/apply_tuple.hpp
View file @
332f9eee
...
@@ -31,9 +31,9 @@
...
@@ -31,9 +31,9 @@
#ifndef APPLY_TUPLE_HPP
#ifndef APPLY_TUPLE_HPP
#define APPLY_TUPLE_HPP
#define APPLY_TUPLE_HPP
#include <type_traits>
#include "cppa/get.hpp"
#include "cppa/get.hpp"
#include "cppa/util/enable_if.hpp"
#include "cppa/util/disable_if.hpp"
#include "cppa/util/is_manipulator.hpp"
#include "cppa/util/is_manipulator.hpp"
#include "cppa/util/callable_trait.hpp"
#include "cppa/util/callable_trait.hpp"
...
...
cppa/util/disable_if.hpp
deleted
100644 → 0
View file @
d3d55a4c
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011, 2012 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation, either version 3 of the License *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef DISABLE_IF_HPP
#define DISABLE_IF_HPP
namespace
cppa
{
namespace
util
{
template
<
bool
Stmt
,
typename
T
=
void
>
struct
disable_if_c
{
};
template
<
typename
T
>
struct
disable_if_c
<
false
,
T
>
{
typedef
T
type
;
};
/**
* @ingroup MetaProgramming
* @brief SFINAE trick to disable a template function based on its
* template parameters.
*/
template
<
class
Trait
,
typename
T
=
void
>
struct
disable_if
:
disable_if_c
<
Trait
::
value
,
T
>
{
};
}
}
// namespace cppa::util
#endif // DISABLE_IF_HPP
cppa/util/is_forward_iterator.hpp
View file @
332f9eee
...
@@ -31,9 +31,9 @@
...
@@ -31,9 +31,9 @@
#ifndef IS_FORWARD_ITERATOR_HPP
#ifndef IS_FORWARD_ITERATOR_HPP
#define IS_FORWARD_ITERATOR_HPP
#define IS_FORWARD_ITERATOR_HPP
#include <type_traits>
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/enable_if.hpp"
#include "cppa/util/disable_if.hpp"
namespace
cppa
{
namespace
util
{
namespace
cppa
{
namespace
util
{
...
@@ -52,11 +52,11 @@ class is_forward_iterator
...
@@ -52,11 +52,11 @@ class is_forward_iterator
// check for 'C::value_type C::operator*()' returning a non-void type
// check for 'C::value_type C::operator*()' returning a non-void type
typename
rm_ref
<
decltype
(
*
(
*
iter
))
>::
type
*
=
0
,
typename
rm_ref
<
decltype
(
*
(
*
iter
))
>::
type
*
=
0
,
// check for 'C& C::operator++()'
// check for 'C& C::operator++()'
typename
enable_if
<
std
::
is_same
<
C
&
,
decltype
(
++
(
*
iter
))
>
>::
type
*
=
0
,
typename
std
::
enable_if
<
std
::
is_same
<
C
&
,
decltype
(
++
(
*
iter
))
>::
value
>::
type
*
=
0
,
// check for 'bool C::operator==()'
// check for 'bool C::operator==()'
typename
enable_if
<
std
::
is_same
<
bool
,
decltype
(
*
iter
==
*
iter
)
>
>::
type
*
=
0
,
typename
std
::
enable_if
<
std
::
is_same
<
bool
,
decltype
(
*
iter
==
*
iter
)
>::
value
>::
type
*
=
0
,
// check for 'bool C::operator!=()'
// check for 'bool C::operator!=()'
typename
enable_if
<
std
::
is_same
<
bool
,
decltype
(
*
iter
!=
*
iter
)
>
>::
type
*
=
0
typename
std
::
enable_if
<
std
::
is_same
<
bool
,
decltype
(
*
iter
!=
*
iter
)
>::
value
>::
type
*
=
0
)
)
{
{
return
true
;
return
true
;
...
...
cppa/util/is_iterable.hpp
View file @
332f9eee
...
@@ -51,9 +51,9 @@ class is_iterable
...
@@ -51,9 +51,9 @@ class is_iterable
(
(
C
const
*
cc
,
C
const
*
cc
,
// check for 'C::begin()' returning a forward iterator
// check for 'C::begin()' returning a forward iterator
typename
util
::
enable_if
<
util
::
is_forward_iterator
<
decltype
(
cc
->
begin
())
>
>::
type
*
=
0
,
typename
std
::
enable_if
<
util
::
is_forward_iterator
<
decltype
(
cc
->
begin
())
>::
value
>::
type
*
=
0
,
// check for 'C::end()' returning the same kind of forward iterator
// check for 'C::end()' returning the same kind of forward iterator
typename
util
::
enable_if
<
std
::
is_same
<
decltype
(
cc
->
begin
()),
decltype
(
cc
->
end
())
>
>::
type
*
=
0
typename
std
::
enable_if
<
std
::
is_same
<
decltype
(
cc
->
begin
()),
decltype
(
cc
->
end
())
>::
value
>::
type
*
=
0
)
)
{
{
return
true
;
return
true
;
...
...
cppa/util/type_list.hpp
View file @
332f9eee
...
@@ -895,9 +895,12 @@ struct tl_pad_left_impl<List, Size, Size, FillType>
...
@@ -895,9 +895,12 @@ struct tl_pad_left_impl<List, Size, Size, FillType>
template
<
class
List
,
size_t
NewSize
,
typename
FillType
=
void_type
>
template
<
class
List
,
size_t
NewSize
,
typename
FillType
=
void_type
>
struct
tl_pad_left
struct
tl_pad_left
{
{
static_assert
(
NewSize
>=
List
::
size
,
"List too big"
);
//
static_assert(NewSize >= List::size, "List too big");
typedef
typename
tl_pad_left_impl
<
typedef
typename
tl_pad_left_impl
<
List
,
List
::
size
,
NewSize
,
FillType
List
,
List
::
size
,
(
List
::
size
>
NewSize
)
?
List
::
size
:
NewSize
,
FillType
>::
type
>::
type
type
;
type
;
};
};
...
@@ -992,6 +995,18 @@ struct tl_group_by
...
@@ -992,6 +995,18 @@ struct tl_group_by
typedef
typename
tl_group_by_impl
<
List
,
type_list
<>
,
Predicate
>::
type
type
;
typedef
typename
tl_group_by_impl
<
List
,
type_list
<>
,
Predicate
>::
type
type
;
};
};
/**
* @brief Applies the types of the list to @p VarArgTemplate.
*/
template
<
class
List
,
template
<
typename
...
>
class
VarArgTemplate
>
struct
tl_apply
;
template
<
typename
...
Ts
,
template
<
typename
...
>
class
VarArgTemplate
>
struct
tl_apply
<
type_list
<
Ts
...
>
,
VarArgTemplate
>
{
typedef
VarArgTemplate
<
Ts
...
>
type
;
};
/**
/**
* @}
* @}
*/
*/
...
...
examples/math_actor_example.cpp
View file @
332f9eee
...
@@ -21,7 +21,7 @@ void math_fun()
...
@@ -21,7 +21,7 @@ void math_fun()
{
{
reply
(
atom
(
"result"
),
a
+
b
);
reply
(
atom
(
"result"
),
a
+
b
);
},
},
on
(
atom
(
"minus"
),
arg_match
)
>>
[](
int
a
,
int
b
)
on
<
atom
(
"minus"
),
int
,
int
>
(
)
>>
[](
int
a
,
int
b
)
{
{
reply
(
atom
(
"result"
),
a
-
b
);
reply
(
atom
(
"result"
),
a
-
b
);
},
},
...
...
src/binary_deserializer.cpp
View file @
332f9eee
...
@@ -35,10 +35,9 @@
...
@@ -35,10 +35,9 @@
#include <stdexcept>
#include <stdexcept>
#include <type_traits>
#include <type_traits>
#include "cppa/util/enable_if.hpp"
#include "cppa/binary_deserializer.hpp"
#include "cppa/binary_deserializer.hpp"
using
cppa
::
util
::
enable_if
;
using
std
::
enable_if
;
namespace
cppa
{
namespace
cppa
{
...
@@ -57,14 +56,14 @@ inline void range_check(iterator begin, iterator end, size_t read_size)
...
@@ -57,14 +56,14 @@ inline void range_check(iterator begin, iterator end, size_t read_size)
// @returns the next iterator position
// @returns the next iterator position
template
<
typename
T
>
template
<
typename
T
>
iterator
read
(
iterator
,
iterator
,
T
&
,
iterator
read
(
iterator
,
iterator
,
T
&
,
typename
enable_if
<
std
::
is_floating_point
<
T
>
>::
type
*
=
0
)
typename
enable_if
<
std
::
is_floating_point
<
T
>::
value
>::
type
*
=
0
)
{
{
throw
std
::
logic_error
(
"read floating point not implemented yet"
);
throw
std
::
logic_error
(
"read floating point not implemented yet"
);
}
}
template
<
typename
T
>
template
<
typename
T
>
iterator
read
(
iterator
begin
,
iterator
end
,
T
&
storage
,
iterator
read
(
iterator
begin
,
iterator
end
,
T
&
storage
,
typename
enable_if
<
std
::
is_integral
<
T
>
>::
type
*
=
0
)
typename
enable_if
<
std
::
is_integral
<
T
>::
value
>::
type
*
=
0
)
{
{
range_check
(
begin
,
end
,
sizeof
(
T
));
range_check
(
begin
,
end
,
sizeof
(
T
));
memcpy
(
&
storage
,
begin
,
sizeof
(
T
));
memcpy
(
&
storage
,
begin
,
sizeof
(
T
));
...
...
src/binary_serializer.cpp
View file @
332f9eee
...
@@ -33,11 +33,10 @@
...
@@ -33,11 +33,10 @@
#include <cstdint>
#include <cstdint>
#include <type_traits>
#include <type_traits>
#include "cppa/util/enable_if.hpp"
#include "cppa/primitive_variant.hpp"
#include "cppa/primitive_variant.hpp"
#include "cppa/binary_serializer.hpp"
#include "cppa/binary_serializer.hpp"
using
cppa
::
util
::
enable_if
;
using
std
::
enable_if
;
namespace
{
namespace
{
...
@@ -75,7 +74,7 @@ class binary_writer
...
@@ -75,7 +74,7 @@ class binary_writer
template
<
typename
T
>
template
<
typename
T
>
void
operator
()(
const
T
&
value
,
void
operator
()(
const
T
&
value
,
typename
enable_if
<
std
::
is_integral
<
T
>
>::
type
*
=
0
)
typename
enable_if
<
std
::
is_integral
<
T
>::
value
>::
type
*
=
0
)
{
{
m_serializer
->
acquire
(
sizeof
(
T
));
m_serializer
->
acquire
(
sizeof
(
T
));
write_int
(
m_serializer
,
value
);
write_int
(
m_serializer
,
value
);
...
@@ -83,7 +82,7 @@ class binary_writer
...
@@ -83,7 +82,7 @@ class binary_writer
template
<
typename
T
>
template
<
typename
T
>
void
operator
()(
const
T
&
,
void
operator
()(
const
T
&
,
typename
enable_if
<
std
::
is_floating_point
<
T
>
>::
type
*
=
0
)
typename
enable_if
<
std
::
is_floating_point
<
T
>::
value
>::
type
*
=
0
)
{
{
throw
std
::
logic_error
(
"binary_serializer::write_floating_point "
throw
std
::
logic_error
(
"binary_serializer::write_floating_point "
"not implemented yet"
);
"not implemented yet"
);
...
...
src/partial_function.cpp
View file @
332f9eee
...
@@ -37,101 +37,12 @@
...
@@ -37,101 +37,12 @@
namespace
cppa
{
namespace
cppa
{
partial_function
::
partial_function
(
i
nvokable_ptr
&&
ptr
)
partial_function
::
partial_function
(
i
mpl_ptr
&&
ptr
)
:
m_impl
(
std
::
move
(
ptr
)
)
{
{
m_funs
.
push_back
(
ptr
.
release
());
}
}
partial_function
::
partial_function
(
partial_function
&&
other
)
partial_function
::
impl
::~
impl
()
:
m_funs
(
std
::
move
(
other
.
m_funs
))
{
{
}
}
partial_function
&
partial_function
::
operator
=
(
partial_function
&&
other
)
{
m_funs
=
std
::
move
(
other
.
m_funs
);
m_cache
.
clear
();
return
*
this
;
}
auto
partial_function
::
get_cache_entry
(
any_tuple
const
&
value
)
->
cache_entry
&
{
m_dummy
.
first
=
value
.
type_token
();
auto
end
=
m_cache
.
end
();
// note: uses >= for comparison (not a "real" upper bound)
auto
i
=
std
::
upper_bound
(
m_cache
.
begin
(),
end
,
m_dummy
,
[](
cache_element
const
&
lhs
,
cache_element
const
&
rhs
)
{
return
lhs
.
first
>=
rhs
.
first
;
});
// if we didn't found a cache entry ...
if
(
i
==
end
||
i
->
first
!=
m_dummy
.
first
)
{
// ... create one
cache_entry
tmp
;
if
(
value
.
impl_type
()
==
detail
::
tuple_impl_info
::
statically_typed
)
{
// use static type information for optimal caching
for
(
auto
f
=
m_funs
.
begin
();
f
!=
m_funs
.
end
();
++
f
)
{
if
(
f
->
types_match
(
value
))
tmp
.
push_back
(
f
.
ptr
());
}
}
else
{
// "dummy" cache entry with all functions (dynamically typed tuple)
for
(
auto
f
=
m_funs
.
begin
();
f
!=
m_funs
.
end
();
++
f
)
{
tmp
.
push_back
(
f
.
ptr
());
}
}
// m_cache is always sorted,
// due to emplace(upper_bound, ...) insertions
i
=
m_cache
.
emplace
(
i
,
std
::
move
(
m_dummy
.
first
),
std
::
move
(
tmp
));
}
return
i
->
second
;
}
bool
partial_function
::
operator
()(
any_tuple
value
)
{
using
detail
::
invokable
;
auto
&
v
=
get_cache_entry
(
value
);
if
(
value
.
impl_type
()
==
detail
::
tuple_impl_info
::
statically_typed
)
{
return
std
::
any_of
(
v
.
begin
(),
v
.
end
(),
[
&
](
invokable
*
i
)
{
return
i
->
unsafe_invoke
(
value
);
});
}
else
{
return
std
::
any_of
(
v
.
begin
(),
v
.
end
(),
[
&
](
invokable
*
i
)
{
return
i
->
invoke
(
value
);
});
}
}
detail
::
invokable
const
*
partial_function
::
definition_at
(
any_tuple
value
)
{
using
detail
::
invokable
;
auto
&
v
=
get_cache_entry
(
value
);
auto
i
=
(
value
.
impl_type
()
==
detail
::
tuple_impl_info
::
statically_typed
)
?
std
::
find_if
(
v
.
begin
(),
v
.
end
(),
[
&
](
invokable
*
i
)
{
return
i
->
could_invoke
(
value
);})
:
std
::
find_if
(
v
.
begin
(),
v
.
end
(),
[
&
](
invokable
*
i
)
{
return
i
->
invoke
(
value
);
});
return
(
i
!=
v
.
end
())
?
*
i
:
nullptr
;
}
bool
partial_function
::
defined_at
(
any_tuple
const
&
value
)
{
return
definition_at
(
value
)
!=
nullptr
;
}
behavior
operator
,(
partial_function
&&
lhs
,
behavior
&&
rhs
)
{
behavior
bhvr
{
rhs
.
m_timeout
,
std
::
move
(
rhs
.
m_timeout_handler
)};
bhvr
.
get_partial_function
().
splice
(
std
::
move
(
rhs
.
get_partial_function
()),
std
::
move
(
lhs
));
return
bhvr
;
}
}
// namespace cppa
}
// namespace cppa
src/primitive_variant.cpp
View file @
332f9eee
...
@@ -39,14 +39,14 @@ namespace {
...
@@ -39,14 +39,14 @@ namespace {
template
<
class
T
>
template
<
class
T
>
void
ptv_del
(
T
&
,
void
ptv_del
(
T
&
,
typename
util
::
enable_if
<
std
::
is_arithmetic
<
T
>
,
int
>::
type
*
=
0
)
typename
std
::
enable_if
<
std
::
is_arithmetic
<
T
>::
value
>::
type
*
=
0
)
{
{
// arithmetic types don't need destruction
// arithmetic types don't need destruction
}
}
template
<
class
T
>
template
<
class
T
>
void
ptv_del
(
T
&
what
,
void
ptv_del
(
T
&
what
,
typename
util
::
disable_if
<
std
::
is_arithmetic
<
T
>
>::
type
*
=
0
)
typename
std
::
enable_if
<!
std
::
is_arithmetic
<
T
>::
value
>::
type
*
=
0
)
{
{
what
.
~
T
();
what
.
~
T
();
}
}
...
...
src/scheduler.cpp
View file @
332f9eee
...
@@ -123,6 +123,15 @@ void scheduler_helper::time_emitter(scheduler_helper::ptr_type m_self)
...
@@ -123,6 +123,15 @@ void scheduler_helper::time_emitter(scheduler_helper::ptr_type m_self)
on
<
atom
(
":_DIE"
)
>
()
>>
[
&
]()
on
<
atom
(
":_DIE"
)
>
()
>>
[
&
]()
{
{
done
=
true
;
done
=
true
;
},
others
()
>>
[
&
]()
{
# ifdef CPPA_DEBUG
std
::
cerr
<<
"scheduler_helper::time_emitter: UNKNOWN MESSAGE: "
<<
to_string
(
msg_ptr
->
msg
)
<<
std
::
endl
;
# endif
msg_ptr
.
reset
();
}
}
);
);
// loop
// loop
...
...
src/uniform_type_info.cpp
View file @
332f9eee
...
@@ -53,8 +53,6 @@
...
@@ -53,8 +53,6 @@
#include "cppa/util/duration.hpp"
#include "cppa/util/duration.hpp"
#include "cppa/util/void_type.hpp"
#include "cppa/util/void_type.hpp"
#include "cppa/util/enable_if.hpp"
#include "cppa/util/disable_if.hpp"
#include "cppa/detail/demangle.hpp"
#include "cppa/detail/demangle.hpp"
#include "cppa/detail/object_array.hpp"
#include "cppa/detail/object_array.hpp"
...
@@ -639,8 +637,7 @@ class int_tinfo : public detail::default_uniform_type_info_impl<T>
...
@@ -639,8 +637,7 @@ class int_tinfo : public detail::default_uniform_type_info_impl<T>
};
};
using
std
::
is_integral
;
using
std
::
is_integral
;
using
util
::
enable_if
;
using
std
::
enable_if
;
using
util
::
disable_if
;
class
uniform_type_info_map_helper
class
uniform_type_info_map_helper
{
{
...
@@ -664,7 +661,7 @@ class uniform_type_info_map_helper
...
@@ -664,7 +661,7 @@ class uniform_type_info_map_helper
template
<
typename
T
>
template
<
typename
T
>
static
inline
void
insert
(
this_ptr
d
,
static
inline
void
insert
(
this_ptr
d
,
std
::
set
<
std
::
string
>
const
&
tnames
,
std
::
set
<
std
::
string
>
const
&
tnames
,
typename
enable_if
<
is_integral
<
T
>>::
type
*
=
0
)
typename
enable_if
<
is_integral
<
T
>
::
value
>::
type
*
=
0
)
{
{
insert
(
d
,
new
int_tinfo
<
T
>
,
tnames
);
insert
(
d
,
new
int_tinfo
<
T
>
,
tnames
);
}
}
...
@@ -672,7 +669,7 @@ class uniform_type_info_map_helper
...
@@ -672,7 +669,7 @@ class uniform_type_info_map_helper
template
<
typename
T
>
template
<
typename
T
>
static
inline
void
insert
(
this_ptr
d
,
static
inline
void
insert
(
this_ptr
d
,
std
::
set
<
std
::
string
>
const
&
tnames
,
std
::
set
<
std
::
string
>
const
&
tnames
,
typename
disable_if
<
is_integral
<
T
>
>::
type
*
=
0
)
typename
enable_if
<!
is_integral
<
T
>::
value
>::
type
*
=
0
)
{
{
insert
(
d
,
new
default_uniform_type_info_impl
<
T
>
(),
tnames
);
insert
(
d
,
new
default_uniform_type_info_impl
<
T
>
(),
tnames
);
}
}
...
...
unit_testing/main.cpp
View file @
332f9eee
...
@@ -148,7 +148,7 @@ int main(int argc, char** argv)
...
@@ -148,7 +148,7 @@ int main(int argc, char** argv)
auto
args
=
get_kv_pairs
(
argc
,
argv
);
auto
args
=
get_kv_pairs
(
argc
,
argv
);
match_each
(
args
)
match_each
(
args
)
(
(
on
(
"run"
,
arg_match
)
>>
[
&
](
std
::
string
const
&
what
)
on
(
"run"
,
val
<
std
::
string
>
)
>>
[
&
](
std
::
string
const
&
what
)
{
{
if
(
what
==
"remote_actor"
)
if
(
what
==
"remote_actor"
)
{
{
...
@@ -156,7 +156,7 @@ int main(int argc, char** argv)
...
@@ -156,7 +156,7 @@ int main(int argc, char** argv)
exit
(
0
);
exit
(
0
);
}
}
},
},
on
(
"scheduler"
,
arg_match
)
>>
[](
std
::
string
const
&
sched
)
on
(
"scheduler"
,
val
<
std
::
string
>
)
>>
[](
std
::
string
const
&
sched
)
{
{
if
(
sched
==
"thread_pool_scheduler"
)
if
(
sched
==
"thread_pool_scheduler"
)
{
{
...
...
unit_testing/test.hpp
View file @
332f9eee
...
@@ -8,19 +8,22 @@
...
@@ -8,19 +8,22 @@
#include <iostream>
#include <iostream>
#include <type_traits>
#include <type_traits>
#include "cppa/util/enable_if.hpp"
#include "cppa/util/disable_if.hpp"
template
<
typename
T1
,
typename
T2
>
template
<
typename
T1
,
typename
T2
>
inline
bool
cppa_check_value_fun_eq
(
T1
const
&
value1
,
T2
const
&
value2
,
inline
bool
cppa_check_value_fun_eq
(
T1
const
&
value1
,
T2
const
&
value2
,
typename
cppa
::
util
::
disable_if_c
<
std
::
is_integral
<
T1
>::
value
&&
std
::
is_integral
<
T2
>::
value
>::
type
*
=
0
)
typename
std
::
enable_if
<
!
std
::
is_integral
<
T1
>::
value
||
!
std
::
is_integral
<
T2
>::
value
>::
type
*
=
0
)
{
{
return
value1
==
value2
;
return
value1
==
value2
;
}
}
template
<
typename
T1
,
typename
T2
>
template
<
typename
T1
,
typename
T2
>
inline
bool
cppa_check_value_fun_eq
(
T1
value1
,
T2
value2
,
inline
bool
cppa_check_value_fun_eq
(
T1
value1
,
T2
value2
,
typename
cppa
::
util
::
enable_if_c
<
std
::
is_integral
<
T1
>::
value
&&
std
::
is_integral
<
T2
>::
value
>::
type
*
=
0
)
typename
std
::
enable_if
<
std
::
is_integral
<
T1
>::
value
&&
std
::
is_integral
<
T2
>::
value
>::
type
*
=
0
)
{
{
return
value1
==
static_cast
<
T1
>
(
value2
);
return
value1
==
static_cast
<
T1
>
(
value2
);
}
}
...
...
unit_testing/test__match.cpp
View file @
332f9eee
...
@@ -175,7 +175,7 @@ size_t test__match()
...
@@ -175,7 +175,7 @@ size_t test__match()
vector
<
string
>
vec
{
"a"
,
"b"
,
"c"
};
vector
<
string
>
vec
{
"a"
,
"b"
,
"c"
};
match
(
vec
)
match
(
vec
)
(
(
on
(
"a"
,
"b"
,
arg_match
)
>>
[
&
](
string
&
str
)
on
(
"a"
,
"b"
,
val
<
string
>
)
>>
[
&
](
string
&
str
)
{
{
invoked
=
true
;
invoked
=
true
;
str
=
"C"
;
str
=
"C"
;
...
@@ -197,6 +197,7 @@ size_t test__match()
...
@@ -197,6 +197,7 @@ size_t test__match()
CPPA_CHECK_EQUAL
(
"A"
,
vec
.
front
());
CPPA_CHECK_EQUAL
(
"A"
,
vec
.
front
());
invoked
=
false
;
invoked
=
false
;
/*
match(vec)
match(vec)
(
(
others() >> [&](any_tuple& tup)
others() >> [&](any_tuple& tup)
...
@@ -214,7 +215,7 @@ size_t test__match()
...
@@ -214,7 +215,7 @@ size_t test__match()
);
);
if (!invoked) { CPPA_ERROR("match({\"a\", \"b\", \"c\"}) failed"); }
if (!invoked) { CPPA_ERROR("match({\"a\", \"b\", \"c\"}) failed"); }
CPPA_CHECK_EQUAL(vec[1], "B");
CPPA_CHECK_EQUAL(vec[1], "B");
invoked
=
false
;
*/
vector
<
string
>
vec2
{
"a=0"
,
"b=1"
,
"c=2"
};
vector
<
string
>
vec2
{
"a=0"
,
"b=1"
,
"c=2"
};
...
@@ -226,34 +227,36 @@ size_t test__match()
...
@@ -226,34 +227,36 @@ size_t test__match()
CPPA_CHECK_EQUAL
(
true
,
invoked
);
CPPA_CHECK_EQUAL
(
true
,
invoked
);
invoked
=
false
;
invoked
=
false
;
/*,
int pmatches = 0;
int pmatches = 0;
using std::placeholders::_1;
using std::placeholders::_1;
pmatch_each(vec2.begin(), vec2.end(), std::bind(split, _1, '='))
pmatch_each(vec2.begin(), vec2.end(), std::bind(split, _1, '='))
(
(
on
(
"a"
,
arg_match
)
>>
[
&
](
string
const
&
value
)
on("a",
val<string>
) >> [&](string const& value)
{
{
CPPA_CHECK_EQUAL("0", value);
CPPA_CHECK_EQUAL("0", value);
CPPA_CHECK_EQUAL(0, pmatches);
CPPA_CHECK_EQUAL(0, pmatches);
++pmatches;
++pmatches;
},
},
on
(
"b"
,
arg_match
)
>>
[
&
](
string
const
&
value
)
on("b",
val<string>
) >> [&](string const& value)
{
{
CPPA_CHECK_EQUAL("1", value);
CPPA_CHECK_EQUAL("1", value);
CPPA_CHECK_EQUAL(1, pmatches);
CPPA_CHECK_EQUAL(1, pmatches);
++pmatches;
++pmatches;
},
},
on
(
"c"
,
arg_match
)
>>
[
&
](
string
const
&
value
)
on("c",
val<string>
) >> [&](string const& value)
{
{
CPPA_CHECK_EQUAL("2", value);
CPPA_CHECK_EQUAL("2", value);
CPPA_CHECK_EQUAL(2, pmatches);
CPPA_CHECK_EQUAL(2, pmatches);
++pmatches;
++pmatches;
}
,
}
others() >> [](any_tuple const& value)
others() >> [](any_tuple const& value)
{
{
cout << to_string(value) << endl;
cout << to_string(value) << endl;
}
}
);
);
CPPA_CHECK_EQUAL(3, pmatches);
CPPA_CHECK_EQUAL(3, pmatches);
*/
return
CPPA_TEST_RESULT
;
return
CPPA_TEST_RESULT
;
}
}
unit_testing/test__pattern.cpp
View file @
332f9eee
...
@@ -14,8 +14,6 @@
...
@@ -14,8 +14,6 @@
#include "cppa/tuple_cast.hpp"
#include "cppa/tuple_cast.hpp"
#include "cppa/partial_function.hpp"
#include "cppa/partial_function.hpp"
#include "cppa/util/enable_if.hpp"
#include "cppa/util/disable_if.hpp"
#include "cppa/util/apply_tuple.hpp"
#include "cppa/util/apply_tuple.hpp"
#include "cppa/util/is_primitive.hpp"
#include "cppa/util/is_primitive.hpp"
#include "cppa/util/is_mutable_ref.hpp"
#include "cppa/util/is_mutable_ref.hpp"
...
...
unit_testing/test__serialization.cpp
View file @
332f9eee
...
@@ -41,8 +41,6 @@
...
@@ -41,8 +41,6 @@
#include "cppa/binary_deserializer.hpp"
#include "cppa/binary_deserializer.hpp"
#include "cppa/util/pt_token.hpp"
#include "cppa/util/pt_token.hpp"
#include "cppa/util/enable_if.hpp"
#include "cppa/util/disable_if.hpp"
#include "cppa/util/is_iterable.hpp"
#include "cppa/util/is_iterable.hpp"
#include "cppa/util/is_primitive.hpp"
#include "cppa/util/is_primitive.hpp"
#include "cppa/util/abstract_uniform_type_info.hpp"
#include "cppa/util/abstract_uniform_type_info.hpp"
...
...
unit_testing/test__spawn.cpp
View file @
332f9eee
...
@@ -330,6 +330,11 @@ size_t test__spawn()
...
@@ -330,6 +330,11 @@ size_t test__spawn()
{
{
CPPA_TEST
(
test__spawn
);
CPPA_TEST
(
test__spawn
);
CPPA_IF_VERBOSE
(
cout
<<
"test send() ... "
<<
std
::
flush
);
send
(
self
,
1
,
2
,
3
);
receive
(
on
(
1
,
2
,
3
)
>>
[]()
{
});
CPPA_IF_VERBOSE
(
cout
<<
"ok"
<<
endl
);
CPPA_IF_VERBOSE
(
cout
<<
"test future_send() ... "
<<
std
::
flush
);
CPPA_IF_VERBOSE
(
cout
<<
"test future_send() ... "
<<
std
::
flush
);
future_send
(
self
,
std
::
chrono
::
seconds
(
1
),
1
,
2
,
3
);
future_send
(
self
,
std
::
chrono
::
seconds
(
1
),
1
,
2
,
3
);
receive
(
on
(
1
,
2
,
3
)
>>
[]()
{
});
receive
(
on
(
1
,
2
,
3
)
>>
[]()
{
});
...
...
unit_testing/test__tuple.cpp
View file @
332f9eee
This diff is collapsed.
Click to expand it.
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