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
aa09f262
Commit
aa09f262
authored
Feb 29, 2012
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
maintenance
parent
3af4eb8f
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
120 additions
and
104 deletions
+120
-104
cppa/any_tuple.hpp
cppa/any_tuple.hpp
+5
-2
cppa/anything.hpp
cppa/anything.hpp
+9
-0
cppa/detail/abstract_tuple.hpp
cppa/detail/abstract_tuple.hpp
+2
-2
cppa/detail/decorated_tuple.hpp
cppa/detail/decorated_tuple.hpp
+2
-12
cppa/detail/empty_tuple.hpp
cppa/detail/empty_tuple.hpp
+1
-0
cppa/detail/object_array.hpp
cppa/detail/object_array.hpp
+1
-1
cppa/detail/tuple_cast_impl.hpp
cppa/detail/tuple_cast_impl.hpp
+6
-8
cppa/detail/tuple_vals.hpp
cppa/detail/tuple_vals.hpp
+2
-2
cppa/detail/types_array.hpp
cppa/detail/types_array.hpp
+12
-2
cppa/invoke_rules.hpp
cppa/invoke_rules.hpp
+1
-1
cppa/match.hpp
cppa/match.hpp
+40
-54
cppa/pattern.hpp
cppa/pattern.hpp
+24
-2
cppa/tuple_cast.hpp
cppa/tuple_cast.hpp
+4
-6
src/any_tuple.cpp
src/any_tuple.cpp
+0
-5
src/empty_tuple.cpp
src/empty_tuple.cpp
+2
-2
src/invoke_rules.cpp
src/invoke_rules.cpp
+7
-3
src/object_array.cpp
src/object_array.cpp
+2
-2
No files found.
cppa/any_tuple.hpp
View file @
aa09f262
...
@@ -141,10 +141,13 @@ class any_tuple
...
@@ -141,10 +141,13 @@ class any_tuple
inline
const_iterator
end
()
const
{
return
m_vals
->
end
();
}
inline
const_iterator
end
()
const
{
return
m_vals
->
end
();
}
std
::
type_info
const
&
impl_type
()
const
;
cow_ptr
<
detail
::
abstract_tuple
>
const
&
vals
()
const
;
cow_ptr
<
detail
::
abstract_tuple
>
const
&
vals
()
const
;
inline
std
::
type_info
const
*
values_type_list
()
const
{
return
m_vals
->
values_type_list
();
}
};
};
inline
bool
operator
==
(
any_tuple
const
&
lhs
,
any_tuple
const
&
rhs
)
inline
bool
operator
==
(
any_tuple
const
&
lhs
,
any_tuple
const
&
rhs
)
...
...
cppa/anything.hpp
View file @
aa09f262
...
@@ -31,6 +31,8 @@
...
@@ -31,6 +31,8 @@
#ifndef LIBCPPA_ANYTHING_HPP
#ifndef LIBCPPA_ANYTHING_HPP
#define LIBCPPA_ANYTHING_HPP
#define LIBCPPA_ANYTHING_HPP
#include <type_traits>
namespace
cppa
{
namespace
cppa
{
/**
/**
...
@@ -48,6 +50,13 @@ inline bool operator!=(anything const&, anything const&)
...
@@ -48,6 +50,13 @@ inline bool operator!=(anything const&, anything const&)
return
false
;
return
false
;
}
}
template
<
typename
T
>
struct
is_anything
{
static
constexpr
bool
value
=
std
::
is_same
<
T
,
anything
>::
value
;
};
}
// namespace cppa
}
// namespace cppa
#endif // ANYTHING_HPP
#endif // ANYTHING_HPP
cppa/detail/abstract_tuple.hpp
View file @
aa09f262
...
@@ -56,8 +56,8 @@ struct abstract_tuple : ref_counted
...
@@ -56,8 +56,8 @@ struct abstract_tuple : ref_counted
virtual
abstract_tuple
*
copy
()
const
=
0
;
virtual
abstract_tuple
*
copy
()
const
=
0
;
virtual
void
const
*
at
(
size_t
pos
)
const
=
0
;
virtual
void
const
*
at
(
size_t
pos
)
const
=
0
;
virtual
uniform_type_info
const
*
type_at
(
size_t
pos
)
const
=
0
;
virtual
uniform_type_info
const
*
type_at
(
size_t
pos
)
const
=
0
;
// type
of the implementation class
// type
_list of values or nullptr
virtual
std
::
type_info
const
&
impl_type
()
const
=
0
;
virtual
std
::
type_info
const
*
values_type_list
()
const
=
0
;
bool
equals
(
abstract_tuple
const
&
other
)
const
;
bool
equals
(
abstract_tuple
const
&
other
)
const
;
...
...
cppa/detail/decorated_tuple.hpp
View file @
aa09f262
...
@@ -102,19 +102,9 @@ class decorated_tuple : public abstract_tuple
...
@@ -102,19 +102,9 @@ class decorated_tuple : public abstract_tuple
return
m_decorated
->
type_at
(
m_mapping
[
pos
]);
return
m_decorated
->
type_at
(
m_mapping
[
pos
]);
}
}
virtual
std
::
type_info
const
&
impl_type
()
const
std
::
type_info
const
*
values_type_list
()
const
{
{
return
typeid
(
decorated_tuple
);
return
detail
::
static_type_list
<
ElementTypes
...
>::
list
;
}
cow_pointer_type
&
decorated
()
{
return
m_decorated
;
}
cow_pointer_type
const
&
decorated
()
const
{
return
m_decorated
;
}
}
private:
private:
...
...
cppa/detail/empty_tuple.hpp
View file @
aa09f262
...
@@ -47,6 +47,7 @@ struct empty_tuple : abstract_tuple
...
@@ -47,6 +47,7 @@ struct empty_tuple : abstract_tuple
bool
equals
(
abstract_tuple
const
&
other
)
const
;
bool
equals
(
abstract_tuple
const
&
other
)
const
;
uniform_type_info
const
*
type_at
(
size_t
)
const
;
uniform_type_info
const
*
type_at
(
size_t
)
const
;
std
::
type_info
const
&
impl_type
()
const
;
std
::
type_info
const
&
impl_type
()
const
;
std
::
type_info
const
*
values_type_list
()
const
;
};
};
...
...
cppa/detail/object_array.hpp
View file @
aa09f262
...
@@ -68,7 +68,7 @@ class object_array : public abstract_tuple
...
@@ -68,7 +68,7 @@ class object_array : public abstract_tuple
uniform_type_info
const
*
type_at
(
size_t
pos
)
const
;
uniform_type_info
const
*
type_at
(
size_t
pos
)
const
;
std
::
type_info
const
&
impl_type
()
const
;
std
::
type_info
const
*
values_type_list
()
const
;
};
};
...
...
cppa/detail/tuple_cast_impl.hpp
View file @
aa09f262
...
@@ -52,13 +52,11 @@ enum class tuple_cast_impl_id
...
@@ -52,13 +52,11 @@ enum class tuple_cast_impl_id
};
};
// covers wildcard_in_between and multiple_wildcards
// covers wildcard_in_between and multiple_wildcards
template
<
pattern_characteristic
,
class
Result
,
typename
...
T
>
template
<
wildcard_position
,
class
Result
,
typename
...
T
>
struct
tuple_cast_impl
struct
tuple_cast_impl
{
{
static
constexpr
size_t
size
=
static
constexpr
size_t
size
=
util
::
tl_count_not
<
util
::
tl_count_not
<
util
::
type_list
<
T
...
>
,
is_anything
>::
value
;
util
::
type_list
<
T
...
>
,
util
::
tbind
<
std
::
is_same
,
anything
>::
type
>::
value
;
typedef
util
::
fixed_vector
<
size_t
,
size
>
mapping_vector
;
typedef
util
::
fixed_vector
<
size_t
,
size
>
mapping_vector
;
template
<
class
Tuple
>
template
<
class
Tuple
>
inline
static
option
<
Result
>
_
(
Tuple
const
&
tup
)
inline
static
option
<
Result
>
_
(
Tuple
const
&
tup
)
...
@@ -77,7 +75,7 @@ struct tuple_cast_impl
...
@@ -77,7 +75,7 @@ struct tuple_cast_impl
};
};
template
<
class
Result
,
typename
...
T
>
template
<
class
Result
,
typename
...
T
>
struct
tuple_cast_impl
<
pattern_characteristic
::
no_wildcard
,
Result
,
T
...
>
struct
tuple_cast_impl
<
wildcard_position
::
nil
,
Result
,
T
...
>
{
{
template
<
class
Tuple
>
template
<
class
Tuple
>
static
inline
option
<
Result
>
_
(
Tuple
const
&
tup
)
static
inline
option
<
Result
>
_
(
Tuple
const
&
tup
)
...
@@ -94,13 +92,13 @@ struct tuple_cast_impl<pattern_characteristic::no_wildcard, Result, T...>
...
@@ -94,13 +92,13 @@ struct tuple_cast_impl<pattern_characteristic::no_wildcard, Result, T...>
};
};
template
<
class
Result
,
typename
...
T
>
template
<
class
Result
,
typename
...
T
>
struct
tuple_cast_impl
<
pattern_characteristic
::
trailing_wildcard
,
Result
,
T
...
>
struct
tuple_cast_impl
<
wildcard_position
::
trailing
,
Result
,
T
...
>
:
tuple_cast_impl
<
pattern_characteristic
::
no_wildcard
,
Result
,
T
...
>
:
tuple_cast_impl
<
wildcard_position
::
nil
,
Result
,
T
...
>
{
{
};
};
template
<
class
Result
,
typename
...
T
>
template
<
class
Result
,
typename
...
T
>
struct
tuple_cast_impl
<
pattern_characteristic
::
leading_wildcard
,
Result
,
T
...
>
struct
tuple_cast_impl
<
wildcard_position
::
leading
,
Result
,
T
...
>
{
{
template
<
class
Tuple
>
template
<
class
Tuple
>
inline
static
option
<
Result
>
_
(
Tuple
const
&
tup
)
inline
static
option
<
Result
>
_
(
Tuple
const
&
tup
)
...
...
cppa/detail/tuple_vals.hpp
View file @
aa09f262
...
@@ -112,9 +112,9 @@ class tuple_vals : public abstract_tuple
...
@@ -112,9 +112,9 @@ class tuple_vals : public abstract_tuple
return
abstract_tuple
::
equals
(
other
);
return
abstract_tuple
::
equals
(
other
);
}
}
std
::
type_info
const
&
impl_type
()
const
std
::
type_info
const
*
values_type_list
()
const
{
{
return
typeid
(
tuple_vals
)
;
return
detail
::
static_type_list
<
ElementTypes
...
>::
list
;
}
}
};
};
...
...
cppa/detail/types_array.hpp
View file @
aa09f262
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
#include "cppa/type_value_pair.hpp"
#include "cppa/type_value_pair.hpp"
#include "cppa/util/tbind.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/is_builtin.hpp"
#include "cppa/util/is_builtin.hpp"
...
@@ -159,12 +158,13 @@ struct types_array : types_array_impl<util::tl_forall<util::type_list<T...>,
...
@@ -159,12 +158,13 @@ struct types_array : types_array_impl<util::tl_forall<util::type_list<T...>,
{
{
static
constexpr
size_t
size
=
sizeof
...(
T
);
static
constexpr
size_t
size
=
sizeof
...(
T
);
typedef
util
::
type_list
<
T
...
>
types
;
typedef
util
::
type_list
<
T
...
>
types
;
typedef
typename
util
::
tl_filter_not
<
types
,
util
::
tbind
<
std
::
is_same
,
anything
>::
type
>::
type
typedef
typename
util
::
tl_filter_not
<
types
,
is_anything
>::
type
filtered_types
;
filtered_types
;
static
constexpr
size_t
filtered_size
=
filtered_types
::
size
;
static
constexpr
size_t
filtered_size
=
filtered_types
::
size
;
inline
bool
has_values
()
const
{
return
false
;
}
inline
bool
has_values
()
const
{
return
false
;
}
};
};
// utility for singleton-like access to a types_array
template
<
typename
...
T
>
template
<
typename
...
T
>
struct
static_types_array
struct
static_types_array
{
{
...
@@ -183,6 +183,16 @@ struct static_types_array_from_type_list<util::type_list<T...>>
...
@@ -183,6 +183,16 @@ struct static_types_array_from_type_list<util::type_list<T...>>
typedef
static_types_array
<
T
...
>
type
;
typedef
static_types_array
<
T
...
>
type
;
};
};
// utility for singleton-like access to a type_info instance of a type_list
template
<
typename
...
T
>
struct
static_type_list
{
static
std
::
type_info
const
*
list
;
};
template
<
typename
...
T
>
std
::
type_info
const
*
static_type_list
<
T
...
>::
list
=
&
typeid
(
util
::
type_list
<
T
...
>
);
}
}
// namespace cppa::detail
}
}
// namespace cppa::detail
#endif // TYPES_ARRAY_HPP
#endif // TYPES_ARRAY_HPP
cppa/invoke_rules.hpp
View file @
aa09f262
...
@@ -52,7 +52,7 @@ class any_tuple;
...
@@ -52,7 +52,7 @@ class any_tuple;
class
invoke_rules
;
class
invoke_rules
;
class
timed_invoke_rules
;
class
timed_invoke_rules
;
typedef
std
::
list
<
detail
::
invokable_ptr
>
invokable_list
;
typedef
std
::
vector
<
detail
::
invokable_ptr
>
invokable_list
;
/**
/**
* @brief Base of {@link timed_invoke_rules} and {@link invoke_rules}.
* @brief Base of {@link timed_invoke_rules} and {@link invoke_rules}.
...
...
cppa/match.hpp
View file @
aa09f262
...
@@ -36,7 +36,6 @@
...
@@ -36,7 +36,6 @@
#include "cppa/pattern.hpp"
#include "cppa/pattern.hpp"
#include "cppa/anything.hpp"
#include "cppa/anything.hpp"
#include "cppa/any_tuple.hpp"
#include "cppa/any_tuple.hpp"
#include "cppa/util/tbind.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/detail/tuple_vals.hpp"
#include "cppa/detail/tuple_vals.hpp"
...
@@ -46,34 +45,27 @@
...
@@ -46,34 +45,27 @@
namespace
cppa
{
namespace
cppa
{
enum
class
pattern_characteristic
namespace
detail
{
{
no_wildcard
,
trailing_wildcard
,
leading_wildcard
,
wildcard_in_between
,
multiple_wildcards
};
t
emplate
<
typename
Types
>
t
ypedef
std
::
integral_constant
<
wildcard_position
,
constexpr
pattern_characteristic
get_pattern_characteristic
()
wildcard_position
::
nil
>
{
no_wildcard
;
return
util
::
tl_exists
<
Types
,
util
::
tbind
<
std
::
is_same
,
anything
>::
type
>::
value
?
((
util
::
tl_count
<
Types
,
util
::
tbind
<
std
::
is_same
,
anything
>::
type
>::
value
==
1
)
bool
tmatch
(
no_wildcard
,
?
(
std
::
is_same
<
typename
Types
::
head
,
anything
>::
value
std
::
type_info
const
*
tuple_value_type_list
,
?
pattern_characteristic
::
leading_wildcard
any_tuple
::
const_iterator
const
&
tuple_begin
,
:
(
std
::
is_same
<
typename
Types
::
back
,
anything
>::
value
any_tuple
::
const_iterator
const
&
tuple_end
,
?
pattern_characteristic
::
trailing_wildcard
std
::
type_info
const
*
pattern_type_list
,
:
pattern_characteristic
::
wildcard_in_between
))
type_value_pair_const_iterator
pattern_begin
,
:
pattern_characteristic
::
multiple_wildcards
)
type_value_pair_const_iterator
pattern_end
);
:
pattern_characteristic
::
no_wildcard
;
}
}
// namespace detail
namespace
detail
{
namespace
detail
{
template
<
pattern_characteristic
,
typename
...
>
struct
matcher
;
template
<
wildcard_position
,
typename
...
>
struct
matcher
;
}
// namespace detail
}
// namespace detail
template
<
pattern_characteristic
PC
,
typename
...
Ts
>
template
<
wildcard_position
PC
,
typename
...
Ts
>
struct
match_impl
;
struct
match_impl
;
/**
/**
...
@@ -83,7 +75,7 @@ template<typename... Ts>
...
@@ -83,7 +75,7 @@ template<typename... Ts>
inline
bool
match
(
any_tuple
const
&
tup
)
inline
bool
match
(
any_tuple
const
&
tup
)
{
{
typedef
util
::
type_list
<
Ts
...
>
tl
;
typedef
util
::
type_list
<
Ts
...
>
tl
;
return
match_impl
<
get_
pattern_characteristic
<
tl
>
(),
Ts
...
>::
_
(
tup
);
return
match_impl
<
get_
wildcard_position
<
tl
>
(),
Ts
...
>::
_
(
tup
);
}
}
/**
/**
...
@@ -95,10 +87,10 @@ inline bool match(any_tuple const& tup,
...
@@ -95,10 +87,10 @@ inline bool match(any_tuple const& tup,
size_t
,
size_t
,
util
::
tl_count_not
<
util
::
tl_count_not
<
util
::
type_list
<
Ts
...
>
,
util
::
type_list
<
Ts
...
>
,
util
::
tbind
<
std
::
is_same
,
anything
>::
type
>::
value
>&
mv
)
is_anything
>::
value
>&
mv
)
{
{
typedef
util
::
type_list
<
Ts
...
>
tl
;
typedef
util
::
type_list
<
Ts
...
>
tl
;
return
match_impl
<
get_
pattern_characteristic
<
tl
>
(),
Ts
...
>::
_
(
tup
,
mv
);
return
match_impl
<
get_
wildcard_position
<
tl
>
(),
Ts
...
>::
_
(
tup
,
mv
);
}
}
/**
/**
...
@@ -108,7 +100,7 @@ template<typename... Ts>
...
@@ -108,7 +100,7 @@ template<typename... Ts>
inline
bool
match
(
any_tuple
const
&
tup
,
pattern
<
Ts
...
>
const
&
ptrn
)
inline
bool
match
(
any_tuple
const
&
tup
,
pattern
<
Ts
...
>
const
&
ptrn
)
{
{
typedef
util
::
type_list
<
Ts
...
>
tl
;
typedef
util
::
type_list
<
Ts
...
>
tl
;
return
match_impl
<
get_
pattern_characteristic
<
tl
>
(),
Ts
...
>::
_
(
tup
,
ptrn
);
return
match_impl
<
get_
wildcard_position
<
tl
>
(),
Ts
...
>::
_
(
tup
,
ptrn
);
}
}
/**
/**
...
@@ -120,13 +112,13 @@ inline bool match(any_tuple const& tup,
...
@@ -120,13 +112,13 @@ inline bool match(any_tuple const& tup,
typename
pattern
<
Ts
...
>::
mapping_vector
&
mv
)
typename
pattern
<
Ts
...
>::
mapping_vector
&
mv
)
{
{
typedef
util
::
type_list
<
Ts
...
>
tl
;
typedef
util
::
type_list
<
Ts
...
>
tl
;
return
match_impl
<
get_
pattern_characteristic
<
tl
>
(),
Ts
...
>::
_
(
tup
,
return
match_impl
<
get_
wildcard_position
<
tl
>
(),
Ts
...
>::
_
(
tup
,
ptrn
,
ptrn
,
mv
);
mv
);
}
}
// implementation for zero or one wildcards
// implementation for zero or one wildcards
template
<
pattern_characteristic
PC
,
typename
...
Ts
>
template
<
wildcard_position
PC
,
typename
...
Ts
>
struct
match_impl
struct
match_impl
{
{
static
inline
bool
_
(
any_tuple
const
&
tup
)
static
inline
bool
_
(
any_tuple
const
&
tup
)
...
@@ -161,9 +153,9 @@ struct match_impl
...
@@ -161,9 +153,9 @@ struct match_impl
// implementation for multiple wildcards
// implementation for multiple wildcards
template
<
typename
...
Ts
>
template
<
typename
...
Ts
>
struct
match_impl
<
pattern_characteristic
::
multiple_wildcards
,
Ts
...
>
struct
match_impl
<
wildcard_position
::
multiple
,
Ts
...
>
{
{
static
constexpr
auto
PC
=
pattern_characteristic
::
multiple_wildcards
;
static
constexpr
auto
PC
=
wildcard_position
::
multiple
;
static
inline
bool
_
(
any_tuple
const
&
tup
)
static
inline
bool
_
(
any_tuple
const
&
tup
)
{
{
...
@@ -209,19 +201,19 @@ struct match_impl<pattern_characteristic::multiple_wildcards, Ts...>
...
@@ -209,19 +201,19 @@ struct match_impl<pattern_characteristic::multiple_wildcards, Ts...>
namespace
detail
{
namespace
detail
{
template
<
typename
...
T
>
template
<
typename
...
T
>
struct
matcher
<
pattern_characteristic
::
no_wildcard
,
T
...
>
struct
matcher
<
wildcard_position
::
nil
,
T
...
>
{
{
static
inline
bool
tmatch
(
any_tuple
const
&
tup
)
static
inline
bool
tmatch
(
any_tuple
const
&
tup
)
{
{
// match implementation type if possible
// match implementation type if possible
auto
&
impl_typeid
=
tup
.
impl_type
();
auto
vals
=
tup
.
values_type_list
();
if
(
impl_typeid
==
typeid
(
tuple_vals
<
T
...
>
)
auto
prns
=
detail
::
static_type_list
<
T
...
>::
list
;
||
impl_typeid
==
typeid
(
decorated_tuple
<
T
...
>
)
)
if
(
vals
==
prns
||
*
vals
==
*
prns
)
{
{
return
true
;
return
true
;
}
}
// always use a full dynamic match for object arrays
// always use a full dynamic match for object arrays
else
if
(
impl_typeid
==
typeid
(
detail
::
object_array
)
else
if
(
*
vals
==
typeid
(
detail
::
object_array
)
&&
tup
.
size
()
==
sizeof
...(
T
))
&&
tup
.
size
()
==
sizeof
...(
T
))
{
{
auto
&
tarr
=
detail
::
static_types_array
<
T
...
>::
arr
;
auto
&
tarr
=
detail
::
static_types_array
<
T
...
>::
arr
;
...
@@ -236,9 +228,8 @@ struct matcher<pattern_characteristic::no_wildcard, T...>
...
@@ -236,9 +228,8 @@ struct matcher<pattern_characteristic::no_wildcard, T...>
{
{
if
(
tmatch
(
tup
))
if
(
tmatch
(
tup
))
{
{
size_t
i
=
0
;
mv
.
resize
(
sizeof
...(
T
));
mv
.
resize
(
sizeof
...(
T
));
std
::
generate
(
mv
.
begin
(),
mv
.
end
(),
[
&
]()
{
return
i
++
;
}
);
std
::
iota
(
mv
.
begin
(),
mv
.
end
(),
0
);
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
@@ -252,7 +243,7 @@ struct matcher<pattern_characteristic::no_wildcard, T...>
...
@@ -252,7 +243,7 @@ struct matcher<pattern_characteristic::no_wildcard, T...>
};
};
template
<
typename
...
T
>
template
<
typename
...
T
>
struct
matcher
<
pattern_characteristic
::
trailing_wildcard
,
T
...
>
struct
matcher
<
wildcard_position
::
trailing
,
T
...
>
{
{
static
constexpr
size_t
size
=
sizeof
...(
T
)
-
1
;
static
constexpr
size_t
size
=
sizeof
...(
T
)
-
1
;
...
@@ -273,9 +264,8 @@ struct matcher<pattern_characteristic::trailing_wildcard, T...>
...
@@ -273,9 +264,8 @@ struct matcher<pattern_characteristic::trailing_wildcard, T...>
{
{
if
(
tmatch
(
tup
))
if
(
tmatch
(
tup
))
{
{
size_t
i
=
0
;
mv
.
resize
(
size
);
mv
.
resize
(
size
);
std
::
generate
(
mv
.
begin
(),
mv
.
end
(),
[
&
]()
{
return
i
++
;
}
);
std
::
iota
(
mv
.
begin
(),
mv
.
end
(),
0
);
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
@@ -290,7 +280,7 @@ struct matcher<pattern_characteristic::trailing_wildcard, T...>
...
@@ -290,7 +280,7 @@ struct matcher<pattern_characteristic::trailing_wildcard, T...>
};
};
template
<
>
template
<
>
struct
matcher
<
pattern_characteristic
::
leading_wildcard
,
anything
>
struct
matcher
<
wildcard_position
::
leading
,
anything
>
{
{
static
inline
bool
tmatch
(
any_tuple
const
&
)
static
inline
bool
tmatch
(
any_tuple
const
&
)
{
{
...
@@ -307,7 +297,7 @@ struct matcher<pattern_characteristic::leading_wildcard, anything>
...
@@ -307,7 +297,7 @@ struct matcher<pattern_characteristic::leading_wildcard, anything>
};
};
template
<
typename
...
T
>
template
<
typename
...
T
>
struct
matcher
<
pattern_characteristic
::
leading_wildcard
,
T
...
>
struct
matcher
<
wildcard_position
::
leading
,
T
...
>
{
{
static
constexpr
size_t
size
=
sizeof
...(
T
)
-
1
;
static
constexpr
size_t
size
=
sizeof
...(
T
)
-
1
;
...
@@ -331,9 +321,8 @@ struct matcher<pattern_characteristic::leading_wildcard, T...>
...
@@ -331,9 +321,8 @@ struct matcher<pattern_characteristic::leading_wildcard, T...>
{
{
if
(
tmatch
(
tup
))
if
(
tmatch
(
tup
))
{
{
size_t
i
=
tup
.
size
()
-
size
;
mv
.
resize
(
size
);
mv
.
resize
(
size
);
std
::
generate
(
mv
.
begin
(),
mv
.
end
(),
[
&
]()
{
return
i
++
;
}
);
std
::
iota
(
mv
.
begin
(),
mv
.
end
(),
tup
.
size
()
-
size
);
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
@@ -350,7 +339,7 @@ struct matcher<pattern_characteristic::leading_wildcard, T...>
...
@@ -350,7 +339,7 @@ struct matcher<pattern_characteristic::leading_wildcard, T...>
};
};
template
<
typename
...
T
>
template
<
typename
...
T
>
struct
matcher
<
pattern_characteristic
::
wildcard_
in_between
,
T
...
>
struct
matcher
<
wildcard_position
::
in_between
,
T
...
>
{
{
static
constexpr
int
signed_wc_pos
=
static
constexpr
int
signed_wc_pos
=
util
::
tl_find
<
util
::
type_list
<
T
...
>
,
anything
>::
value
;
util
::
tl_find
<
util
::
type_list
<
T
...
>
,
anything
>::
value
;
...
@@ -389,14 +378,12 @@ struct matcher<pattern_characteristic::wildcard_in_between, T...>
...
@@ -389,14 +378,12 @@ struct matcher<pattern_characteristic::wildcard_in_between, T...>
if
(
tmatch
(
tup
))
if
(
tmatch
(
tup
))
{
{
// first range
// first range
size_t
i
=
0
;
mv
.
resize
(
size
-
1
);
mv
.
resize
(
size
-
1
);
auto
begin
=
mv
.
begin
();
auto
begin
=
mv
.
begin
();
std
::
generate
(
begin
,
begin
+
wc_pos
,
[
&
]()
{
return
i
++
;
}
);
std
::
iota
(
begin
,
begin
+
wc_pos
,
0
);
// second range
// second range
i
=
tup
.
size
()
-
(
size
-
(
wc_pos
+
1
));
begin
=
mv
.
begin
()
+
wc_pos
;
begin
=
mv
.
begin
()
+
wc_pos
;
std
::
generate
(
begin
,
mv
.
end
(),
[
&
]()
{
return
i
++
;
}
);
std
::
iota
(
begin
,
mv
.
end
(),
tup
.
size
()
-
(
size
-
(
wc_pos
+
1
))
);
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
@@ -421,11 +408,10 @@ struct matcher<pattern_characteristic::wildcard_in_between, T...>
...
@@ -421,11 +408,10 @@ struct matcher<pattern_characteristic::wildcard_in_between, T...>
};
};
template
<
typename
...
T
>
template
<
typename
...
T
>
struct
matcher
<
pattern_characteristic
::
multiple_wildcards
,
T
...
>
struct
matcher
<
wildcard_position
::
multiple
,
T
...
>
{
{
static
constexpr
size_t
wc_count
=
static
constexpr
size_t
wc_count
=
util
::
tl_count
<
util
::
type_list
<
T
...
>
,
util
::
tl_count
<
util
::
type_list
<
T
...
>
,
is_anything
>::
value
;
util
::
tbind
<
std
::
is_same
,
anything
>::
type
>::
value
;
static_assert
(
sizeof
...(
T
)
>
wc_count
,
"only wildcards given"
);
static_assert
(
sizeof
...(
T
)
>
wc_count
,
"only wildcards given"
);
...
...
cppa/pattern.hpp
View file @
aa09f262
...
@@ -43,7 +43,6 @@
...
@@ -43,7 +43,6 @@
#include "cppa/type_value_pair.hpp"
#include "cppa/type_value_pair.hpp"
#include "cppa/uniform_type_info.hpp"
#include "cppa/uniform_type_info.hpp"
#include "cppa/util/tbind.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/arg_match_t.hpp"
#include "cppa/util/arg_match_t.hpp"
#include "cppa/util/fixed_vector.hpp"
#include "cppa/util/fixed_vector.hpp"
...
@@ -56,6 +55,29 @@
...
@@ -56,6 +55,29 @@
namespace
cppa
{
namespace
cppa
{
enum
class
wildcard_position
{
nil
,
trailing
,
leading
,
in_between
,
multiple
};
template
<
typename
Types
>
constexpr
wildcard_position
get_wildcard_position
()
{
return
util
::
tl_exists
<
Types
,
is_anything
>::
value
?
((
util
::
tl_count
<
Types
,
is_anything
>::
value
==
1
)
?
(
std
::
is_same
<
typename
Types
::
head
,
anything
>::
value
?
wildcard_position
::
leading
:
(
std
::
is_same
<
typename
Types
::
back
,
anything
>::
value
?
wildcard_position
::
trailing
:
wildcard_position
::
in_between
))
:
wildcard_position
::
multiple
)
:
wildcard_position
::
nil
;
}
template
<
class
ExtendedType
,
class
BasicType
>
template
<
class
ExtendedType
,
class
BasicType
>
ExtendedType
*
extend_pattern
(
BasicType
const
*
p
);
ExtendedType
*
extend_pattern
(
BasicType
const
*
p
);
...
@@ -77,7 +99,7 @@ class pattern
...
@@ -77,7 +99,7 @@ class pattern
typedef
util
::
type_list
<
Types
...
>
types
;
typedef
util
::
type_list
<
Types
...
>
types
;
typedef
typename
util
::
tl_filter_not
<
types
,
util
::
tbind
<
std
::
is_same
,
anything
>::
type
>::
type
typedef
typename
util
::
tl_filter_not
<
types
,
is_anything
>::
type
filtered_types
;
filtered_types
;
static
constexpr
size_t
filtered_size
=
filtered_types
::
size
;
static
constexpr
size_t
filtered_size
=
filtered_types
::
size
;
...
...
cppa/tuple_cast.hpp
View file @
aa09f262
...
@@ -52,7 +52,7 @@ auto tuple_cast(any_tuple const& tup, pattern<T...> const& p)
...
@@ -52,7 +52,7 @@ auto tuple_cast(any_tuple const& tup, pattern<T...> const& p)
typedef
typename
pattern
<
T
...
>::
filtered_types
filtered_types
;
typedef
typename
pattern
<
T
...
>::
filtered_types
filtered_types
;
typedef
typename
tuple_from_type_list
<
filtered_types
>::
type
tuple_type
;
typedef
typename
tuple_from_type_list
<
filtered_types
>::
type
tuple_type
;
static
constexpr
auto
impl
=
static
constexpr
auto
impl
=
get_
pattern_characteristic
<
util
::
type_list
<
T
...
>>
();
get_
wildcard_position
<
util
::
type_list
<
T
...
>>
();
return
detail
::
tuple_cast_impl
<
impl
,
tuple_type
,
T
...
>::
_
(
tup
,
p
);
return
detail
::
tuple_cast_impl
<
impl
,
tuple_type
,
T
...
>::
_
(
tup
,
p
);
}
}
...
@@ -61,16 +61,14 @@ template<typename... T>
...
@@ -61,16 +61,14 @@ template<typename... T>
auto
tuple_cast
(
any_tuple
const
&
tup
)
auto
tuple_cast
(
any_tuple
const
&
tup
)
->
option
<
->
option
<
typename
tuple_from_type_list
<
typename
tuple_from_type_list
<
typename
util
::
tl_filter_not
<
typename
util
::
tl_filter_not
<
util
::
type_list
<
T
...
>
,
util
::
type_list
<
T
...
>
,
is_anything
>::
type
util
::
tbind
<
std
::
is_same
,
anything
>::
type
>::
type
>::
type
>
>::
type
>
{
{
typedef
decltype
(
tuple_cast
<
T
...
>
(
tup
))
result_type
;
typedef
decltype
(
tuple_cast
<
T
...
>
(
tup
))
result_type
;
typedef
typename
result_type
::
value_type
tuple_type
;
typedef
typename
result_type
::
value_type
tuple_type
;
static
constexpr
auto
impl
=
static
constexpr
auto
impl
=
get_
pattern_characteristic
<
util
::
type_list
<
T
...
>>
();
get_
wildcard_position
<
util
::
type_list
<
T
...
>>
();
return
detail
::
tuple_cast_impl
<
impl
,
tuple_type
,
T
...
>::
_
(
tup
);
return
detail
::
tuple_cast_impl
<
impl
,
tuple_type
,
T
...
>::
_
(
tup
);
}
}
...
...
src/any_tuple.cpp
View file @
aa09f262
...
@@ -111,11 +111,6 @@ any_tuple& any_tuple::operator=(any_tuple&& other)
...
@@ -111,11 +111,6 @@ any_tuple& any_tuple::operator=(any_tuple&& other)
return
*
this
;
return
*
this
;
}
}
std
::
type_info
const
&
any_tuple
::
impl_type
()
const
{
return
m_vals
->
impl_type
();
}
size_t
any_tuple
::
size
()
const
size_t
any_tuple
::
size
()
const
{
{
return
m_vals
->
size
();
return
m_vals
->
size
();
...
...
src/empty_tuple.cpp
View file @
aa09f262
...
@@ -63,9 +63,9 @@ bool empty_tuple::equals(const abstract_tuple& other) const
...
@@ -63,9 +63,9 @@ bool empty_tuple::equals(const abstract_tuple& other) const
return
other
.
size
()
==
0
;
return
other
.
size
()
==
0
;
}
}
std
::
type_info
const
&
empty_tuple
::
impl_type
()
const
std
::
type_info
const
*
empty_tuple
::
values_type_list
()
const
{
{
return
typeid
(
empty_tuple
);
return
&
typeid
(
empty_tuple
);
}
}
}
}
// namespace cppa::detail
}
}
// namespace cppa::detail
src/invoke_rules.cpp
View file @
aa09f262
...
@@ -87,7 +87,9 @@ timed_invoke_rules::timed_invoke_rules(invokable_list&& lhs,
...
@@ -87,7 +87,9 @@ timed_invoke_rules::timed_invoke_rules(invokable_list&& lhs,
timed_invoke_rules
&&
rhs
)
timed_invoke_rules
&&
rhs
)
:
super
(
std
::
move
(
lhs
)),
m_ti
(
std
::
move
(
rhs
.
m_ti
))
:
super
(
std
::
move
(
lhs
)),
m_ti
(
std
::
move
(
rhs
.
m_ti
))
{
{
m_list
.
splice
(
m_list
.
begin
(),
rhs
.
m_list
);
std
::
move
(
rhs
.
m_list
.
begin
(),
rhs
.
m_list
.
end
(),
std
::
back_inserter
(
m_list
));
rhs
.
m_list
.
clear
();
//m_list.splice(m_list.begin(), rhs.m_list);
}
}
timed_invoke_rules
&
timed_invoke_rules
::
operator
=
(
timed_invoke_rules
&&
other
)
timed_invoke_rules
&
timed_invoke_rules
::
operator
=
(
timed_invoke_rules
&&
other
)
...
@@ -126,7 +128,8 @@ invoke_rules::invoke_rules(std::unique_ptr<detail::invokable>&& arg)
...
@@ -126,7 +128,8 @@ invoke_rules::invoke_rules(std::unique_ptr<detail::invokable>&& arg)
invoke_rules
&
invoke_rules
::
splice
(
invokable_list
&&
ilist
)
invoke_rules
&
invoke_rules
::
splice
(
invokable_list
&&
ilist
)
{
{
m_list
.
splice
(
m_list
.
end
(),
ilist
);
std
::
move
(
ilist
.
begin
(),
ilist
.
end
(),
std
::
back_inserter
(
m_list
));
ilist
.
clear
();
return
*
this
;
return
*
this
;
}
}
...
@@ -142,7 +145,8 @@ timed_invoke_rules invoke_rules::splice(timed_invoke_rules&& other)
...
@@ -142,7 +145,8 @@ timed_invoke_rules invoke_rules::splice(timed_invoke_rules&& other)
invoke_rules
invoke_rules
::
operator
,(
invoke_rules
&&
other
)
invoke_rules
invoke_rules
::
operator
,(
invoke_rules
&&
other
)
{
{
m_list
.
splice
(
m_list
.
end
(),
other
.
m_list
);
splice
(
std
::
move
(
other
));
//m_list.splice(m_list.end(), other.m_list);
return
std
::
move
(
m_list
);
return
std
::
move
(
m_list
);
}
}
...
...
src/object_array.cpp
View file @
aa09f262
...
@@ -67,9 +67,9 @@ uniform_type_info const* object_array::type_at(size_t pos) const
...
@@ -67,9 +67,9 @@ uniform_type_info const* object_array::type_at(size_t pos) const
return
m_elements
[
pos
].
type
();
return
m_elements
[
pos
].
type
();
}
}
std
::
type_info
const
&
object_array
::
impl_type
()
const
std
::
type_info
const
*
object_array
::
values_type_list
()
const
{
{
return
typeid
(
object_array
);
return
&
typeid
(
object_array
);
}
}
}
}
// namespace cppa::detail
}
}
// namespace cppa::detail
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