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
aa0427cb
Commit
aa0427cb
authored
Feb 17, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iterator interface
parent
5a913696
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
138 additions
and
154 deletions
+138
-154
cppa/any_tuple.hpp
cppa/any_tuple.hpp
+1
-1
cppa/any_tuple_view.hpp
cppa/any_tuple_view.hpp
+0
-6
cppa/detail/abstract_tuple.hpp
cppa/detail/abstract_tuple.hpp
+55
-4
cppa/detail/decorated_tuple.hpp
cppa/detail/decorated_tuple.hpp
+0
-10
cppa/detail/empty_tuple.hpp
cppa/detail/empty_tuple.hpp
+0
-2
cppa/detail/invokable.hpp
cppa/detail/invokable.hpp
+0
-19
cppa/detail/matches.hpp
cppa/detail/matches.hpp
+21
-34
cppa/detail/object_array.hpp
cppa/detail/object_array.hpp
+0
-5
cppa/detail/tuple_vals.hpp
cppa/detail/tuple_vals.hpp
+5
-30
cppa/invoke_rules.hpp
cppa/invoke_rules.hpp
+0
-3
cppa/match.hpp
cppa/match.hpp
+8
-5
cppa/pattern.hpp
cppa/pattern.hpp
+44
-1
cppa/tuple_cast.hpp
cppa/tuple_cast.hpp
+2
-1
src/empty_tuple.cpp
src/empty_tuple.cpp
+0
-10
src/invoke_rules.cpp
src/invoke_rules.cpp
+0
-9
src/object_array.cpp
src/object_array.cpp
+0
-14
unit_testing/test__tuple.cpp
unit_testing/test__tuple.cpp
+2
-0
No files found.
cppa/any_tuple.hpp
View file @
aa0427cb
...
@@ -135,7 +135,7 @@ class any_tuple
...
@@ -135,7 +135,7 @@ class any_tuple
return
*
reinterpret_cast
<
T
*>
(
mutable_at
(
p
));
return
*
reinterpret_cast
<
T
*>
(
mutable_at
(
p
));
}
}
typedef
type_value_pair
const
*
const_iterator
;
typedef
detail
::
abstract_tuple
::
const_iterator
const_iterator
;
inline
const_iterator
begin
()
const
{
return
m_vals
->
begin
();
}
inline
const_iterator
begin
()
const
{
return
m_vals
->
begin
();
}
...
...
cppa/any_tuple_view.hpp
View file @
aa0427cb
...
@@ -152,12 +152,6 @@ class any_tuple_view
...
@@ -152,12 +152,6 @@ class any_tuple_view
return
typeid
(
detail
::
object_array
);
return
typeid
(
detail
::
object_array
);
}
}
typedef
type_value_pair
const
*
const_iterator
;
inline
const_iterator
begin
()
const
{
return
m_values
.
data
();
}
inline
const_iterator
end
()
const
{
return
begin
()
+
m_values
.
size
();
}
};
};
}
// namespace cppa
}
// namespace cppa
...
...
cppa/detail/abstract_tuple.hpp
View file @
aa0427cb
...
@@ -31,6 +31,9 @@
...
@@ -31,6 +31,9 @@
#ifndef ABSTRACT_TUPLE_HPP
#ifndef ABSTRACT_TUPLE_HPP
#define ABSTRACT_TUPLE_HPP
#define ABSTRACT_TUPLE_HPP
#include <iterator>
#include "cppa/config.hpp"
#include "cppa/ref_counted.hpp"
#include "cppa/ref_counted.hpp"
#include "cppa/type_value_pair.hpp"
#include "cppa/type_value_pair.hpp"
#include "cppa/uniform_type_info.hpp"
#include "cppa/uniform_type_info.hpp"
...
@@ -42,14 +45,10 @@ namespace cppa { namespace detail {
...
@@ -42,14 +45,10 @@ namespace cppa { namespace detail {
struct
abstract_tuple
:
ref_counted
struct
abstract_tuple
:
ref_counted
{
{
typedef
type_value_pair
const
*
const_iterator
;
// mutators
// mutators
virtual
void
*
mutable_at
(
size_t
pos
)
=
0
;
virtual
void
*
mutable_at
(
size_t
pos
)
=
0
;
// accessors
// accessors
virtual
const_iterator
begin
()
const
=
0
;
virtual
const_iterator
end
()
const
=
0
;
virtual
size_t
size
()
const
=
0
;
virtual
size_t
size
()
const
=
0
;
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
;
...
@@ -59,6 +58,58 @@ struct abstract_tuple : ref_counted
...
@@ -59,6 +58,58 @@ struct abstract_tuple : ref_counted
bool
equals
(
abstract_tuple
const
&
other
)
const
;
bool
equals
(
abstract_tuple
const
&
other
)
const
;
// iterator support
class
const_iterator
:
public
std
::
iterator
<
std
::
bidirectional_iterator_tag
,
type_value_pair
>
{
size_t
m_pos
;
abstract_tuple
const
&
m_tuple
;
public:
const_iterator
(
abstract_tuple
const
&
tup
,
size_t
pos
=
0
)
:
m_pos
(
pos
),
m_tuple
(
tup
)
{
}
const_iterator
(
const_iterator
const
&
)
=
default
;
inline
bool
operator
==
(
const_iterator
const
&
other
)
const
{
CPPA_REQUIRE
(
&
(
other
.
m_tuple
)
==
&
(
other
.
m_tuple
));
return
other
.
m_pos
==
m_pos
;
}
inline
bool
operator
!=
(
const_iterator
const
&
other
)
const
{
return
!
(
*
this
==
other
);
}
inline
const_iterator
&
operator
++
()
{
++
m_pos
;
return
*
this
;
}
inline
const_iterator
&
operator
--
()
{
CPPA_REQUIRE
(
m_pos
>
0
);
--
m_pos
;
return
*
this
;
}
inline
size_t
position
()
const
{
return
m_pos
;
}
void
const
*
value
()
const
{
return
m_tuple
.
at
(
m_pos
);
}
uniform_type_info
const
*
type
()
const
{
return
m_tuple
.
type_at
(
m_pos
);
}
type_value_pair
operator
*
()
{
return
{
type
(),
value
()};
}
};
inline
const_iterator
begin
()
const
{
return
{
*
this
};
}
inline
const_iterator
end
()
const
{
return
{
*
this
,
size
()};
}
};
};
}
}
// namespace cppa::detail
}
}
// namespace cppa::detail
...
...
cppa/detail/decorated_tuple.hpp
View file @
aa0427cb
...
@@ -72,16 +72,6 @@ class decorated_tuple : public abstract_tuple
...
@@ -72,16 +72,6 @@ class decorated_tuple : public abstract_tuple
init
(
v
);
init
(
v
);
}
}
virtual
const_iterator
begin
()
const
{
return
m_data
;
}
virtual
const_iterator
end
()
const
{
return
static_cast
<
const_iterator
>
(
m_data
)
+
sizeof
...(
ElementTypes
);
}
virtual
void
*
mutable_at
(
size_t
pos
)
virtual
void
*
mutable_at
(
size_t
pos
)
{
{
CPPA_REQUIRE
(
pos
<
size
());
CPPA_REQUIRE
(
pos
<
size
());
...
...
cppa/detail/empty_tuple.hpp
View file @
aa0427cb
...
@@ -40,8 +40,6 @@ struct empty_tuple : abstract_tuple
...
@@ -40,8 +40,6 @@ struct empty_tuple : abstract_tuple
using
abstract_tuple
::
const_iterator
;
using
abstract_tuple
::
const_iterator
;
const_iterator
begin
()
const
;
const_iterator
end
()
const
;
size_t
size
()
const
;
size_t
size
()
const
;
void
*
mutable_at
(
size_t
);
void
*
mutable_at
(
size_t
);
abstract_tuple
*
copy
()
const
;
abstract_tuple
*
copy
()
const
;
...
...
cppa/detail/invokable.hpp
View file @
aa0427cb
...
@@ -38,7 +38,6 @@
...
@@ -38,7 +38,6 @@
#include "cppa/any_tuple.hpp"
#include "cppa/any_tuple.hpp"
#include "cppa/tuple_cast.hpp"
#include "cppa/tuple_cast.hpp"
#include "cppa/util/duration.hpp"
#include "cppa/util/duration.hpp"
#include "cppa/any_tuple_view.hpp"
#include "cppa/util/apply_tuple.hpp"
#include "cppa/util/apply_tuple.hpp"
#include "cppa/util/fixed_vector.hpp"
#include "cppa/util/fixed_vector.hpp"
#include "cppa/util/callable_trait.hpp"
#include "cppa/util/callable_trait.hpp"
...
@@ -62,7 +61,6 @@ class invokable_base
...
@@ -62,7 +61,6 @@ class invokable_base
invokable_base
()
=
default
;
invokable_base
()
=
default
;
virtual
~
invokable_base
();
virtual
~
invokable_base
();
virtual
bool
invoke
(
any_tuple
const
&
)
const
=
0
;
virtual
bool
invoke
(
any_tuple
const
&
)
const
=
0
;
virtual
bool
invoke
(
any_tuple_view
const
&
)
const
=
0
;
};
};
...
@@ -106,13 +104,6 @@ class timed_invokable_impl : public timed_invokable
...
@@ -106,13 +104,6 @@ class timed_invokable_impl : public timed_invokable
return
true
;
return
true
;
}
}
bool
invoke
(
any_tuple_view
const
&
)
const
{
m_target
();
return
true
;
}
};
};
class
invokable
:
public
invokable_base
class
invokable
:
public
invokable_base
...
@@ -163,11 +154,6 @@ class invokable_impl : public invokable
...
@@ -163,11 +154,6 @@ class invokable_impl : public invokable
return
invoke_impl
(
data
);
return
invoke_impl
(
data
);
}
}
bool
invoke
(
any_tuple_view
const
&
data
)
const
{
return
invoke_impl
(
data
);
}
intermediate
*
get_intermediate
(
any_tuple
const
&
data
)
intermediate
*
get_intermediate
(
any_tuple
const
&
data
)
{
{
auto
tuple_option
=
tuple_cast
(
data
,
*
m_pattern
);
auto
tuple_option
=
tuple_cast
(
data
,
*
m_pattern
);
...
@@ -218,11 +204,6 @@ class invokable_impl<0, Fun, Tuple, Pattern> : public invokable
...
@@ -218,11 +204,6 @@ class invokable_impl<0, Fun, Tuple, Pattern> : public invokable
return
invoke_impl
(
data
);
return
invoke_impl
(
data
);
}
}
bool
invoke
(
any_tuple_view
const
&
data
)
const
{
return
invoke_impl
(
data
);
}
intermediate
*
get_intermediate
(
any_tuple
const
&
data
)
intermediate
*
get_intermediate
(
any_tuple
const
&
data
)
{
{
return
matches
(
data
,
*
m_pattern
)
?
&
m_iimpl
:
nullptr
;
return
matches
(
data
,
*
m_pattern
)
?
&
m_iimpl
:
nullptr
;
...
...
cppa/detail/matches.hpp
View file @
aa0427cb
...
@@ -45,23 +45,10 @@
...
@@ -45,23 +45,10 @@
namespace
cppa
{
namespace
detail
{
namespace
cppa
{
namespace
detail
{
template
<
typename
T
>
inline
auto
ptr_type
(
T
&
ptr
,
util
::
enable_if
<
std
::
is_pointer
<
T
>>*
=
0
)
->
T
{
return
ptr
;
}
template
<
typename
T
>
inline
auto
ptr_type
(
T
&
iter
,
util
::
disable_if
<
std
::
is_pointer
<
T
>>*
=
0
)
->
decltype
(
iter
.
operator
->
())
{
return
iter
.
operator
->
();
}
template
<
class
MappingVector
,
typename
Iterator
>
template
<
class
MappingVector
,
typename
Iterator
>
class
push_mapping_decorator
class
push_mapping_decorator
{
{
size_t
pos
;
Iterator
iter
;
Iterator
iter
;
MappingVector
&
mapping
;
MappingVector
&
mapping
;
size_t
commited_size
;
size_t
commited_size
;
...
@@ -71,7 +58,7 @@ class push_mapping_decorator
...
@@ -71,7 +58,7 @@ class push_mapping_decorator
typedef
MappingVector
mapping_vector
;
typedef
MappingVector
mapping_vector
;
push_mapping_decorator
(
Iterator
const
&
i
,
MappingVector
&
mv
)
push_mapping_decorator
(
Iterator
const
&
i
,
MappingVector
&
mv
)
:
pos
(
0
),
iter
(
i
),
mapping
(
mv
),
commited_size
(
0
)
:
iter
(
i
),
mapping
(
mv
),
commited_size
(
0
)
{
{
}
}
...
@@ -79,29 +66,29 @@ class push_mapping_decorator
...
@@ -79,29 +66,29 @@ class push_mapping_decorator
inline
push_mapping_decorator
&
operator
++
()
inline
push_mapping_decorator
&
operator
++
()
{
{
++
pos
;
++
iter
;
++
iter
;
return
*
this
;
return
*
this
;
}
}
inline
bool
operator
==
(
Iterator
const
&
i
)
inline
push_mapping_decorator
&
operator
--
(
)
{
{
return
iter
==
i
;
--
iter
;
return
*
this
;
}
}
inline
decltype
(
*
iter
)
operator
*
()
inline
bool
operator
==
(
Iterator
const
&
i
)
{
return
iter
==
i
;
}
{
return
*
iter
;
}
inline
decltype
(
ptr_type
(
iter
))
operator
->
()
inline
bool
operator
!=
(
Iterator
const
&
i
)
{
return
iter
!=
i
;
}
{
return
ptr_type
(
iter
);
inline
decltype
(
iter
.
value
())
value
()
const
{
return
iter
.
value
();
}
}
inline
decltype
(
iter
.
type
())
type
()
const
{
return
iter
.
type
();
}
inline
size_t
position
()
const
{
return
iter
.
position
();
}
inline
void
push_mapping
()
inline
void
push_mapping
()
{
{
mapping
.
push_back
(
pos
);
mapping
.
push_back
(
pos
ition
()
);
}
}
inline
void
commit_mapping
()
inline
void
commit_mapping
()
...
@@ -150,7 +137,7 @@ template<typename T>
...
@@ -150,7 +137,7 @@ template<typename T>
inline
typename
util
::
enable_if
<
is_pm_decorated
<
T
>
,
void
>::
type
inline
typename
util
::
enable_if
<
is_pm_decorated
<
T
>
,
void
>::
type
push_mapping
(
T
&
iter
)
push_mapping
(
T
&
iter
)
{
{
iter
->
push_mapping
();
iter
.
push_mapping
();
}
}
template
<
typename
T
>
template
<
typename
T
>
...
@@ -161,7 +148,7 @@ template<typename T>
...
@@ -161,7 +148,7 @@ template<typename T>
inline
typename
util
::
enable_if
<
is_pm_decorated
<
T
>
,
void
>::
type
inline
typename
util
::
enable_if
<
is_pm_decorated
<
T
>
,
void
>::
type
commit_mapping
(
T
&
iter
)
commit_mapping
(
T
&
iter
)
{
{
iter
->
commit_mapping
();
iter
.
commit_mapping
();
}
}
template
<
typename
T
>
template
<
typename
T
>
...
@@ -172,20 +159,20 @@ template<typename T>
...
@@ -172,20 +159,20 @@ template<typename T>
inline
typename
util
::
enable_if
<
is_pm_decorated
<
T
>
,
void
>::
type
inline
typename
util
::
enable_if
<
is_pm_decorated
<
T
>
,
void
>::
type
rollback_mapping
(
T
&
iter
)
rollback_mapping
(
T
&
iter
)
{
{
iter
->
rollback_mapping
();
iter
.
rollback_mapping
();
}
}
template
<
class
TupleBeginIterator
,
class
TupleEndIterator
,
class
PatternIterator
>
template
<
class
TupleBeginIterator
,
class
TupleEndIterator
,
class
PatternIterator
>
bool
matches
(
TupleBeginIterator
tbegin
,
TupleEndIterator
tend
,
bool
matches
(
TupleBeginIterator
tbegin
,
TupleEndIterator
tend
,
PatternIterator
pbegin
,
PatternIterator
pend
)
PatternIterator
pbegin
,
PatternIterator
pend
)
{
{
for
(
;
!
(
pbegin
==
pend
&&
tbegin
==
tend
);
++
pbegin
,
++
tbegin
)
while
(
!
(
pbegin
==
pend
&&
tbegin
==
tend
)
)
{
{
if
(
pbegin
==
pend
)
if
(
pbegin
==
pend
)
{
{
return
false
;
return
false
;
}
}
else
if
(
pbegin
->
first
==
nullptr
)
// nullptr == wildcard (anything)
else
if
(
pbegin
.
type
()
==
nullptr
)
// nullptr == wildcard (anything)
{
{
// perform submatching
// perform submatching
++
pbegin
;
++
pbegin
;
...
@@ -206,11 +193,11 @@ bool matches(TupleBeginIterator tbegin, TupleEndIterator tend,
...
@@ -206,11 +193,11 @@ bool matches(TupleBeginIterator tbegin, TupleEndIterator tend,
return
false
;
// no submatch found
return
false
;
// no submatch found
}
}
// compare types
// compare types
else
if
(
tbegin
!=
tend
&&
pbegin
->
first
==
tbegin
->
first
)
else
if
(
tbegin
!=
tend
&&
pbegin
.
type
()
==
tbegin
.
type
()
)
{
{
// compare values if needed
// compare values if needed
if
(
pbegin
->
second
==
nullptr
if
(
pbegin
.
value
()
==
nullptr
||
pbegin
->
first
->
equals
(
pbegin
->
second
,
tbegin
->
second
))
||
pbegin
.
type
()
->
equals
(
pbegin
.
value
(),
tbegin
.
value
()
))
{
{
push_mapping
(
tbegin
);
push_mapping
(
tbegin
);
}
}
...
...
cppa/detail/object_array.hpp
View file @
aa0427cb
...
@@ -43,7 +43,6 @@ class object_array : public abstract_tuple
...
@@ -43,7 +43,6 @@ class object_array : public abstract_tuple
{
{
std
::
vector
<
object
>
m_elements
;
std
::
vector
<
object
>
m_elements
;
std
::
vector
<
type_value_pair
>
m_data
;
public:
public:
...
@@ -61,10 +60,6 @@ class object_array : public abstract_tuple
...
@@ -61,10 +60,6 @@ class object_array : public abstract_tuple
void
*
mutable_at
(
size_t
pos
);
void
*
mutable_at
(
size_t
pos
);
const_iterator
begin
()
const
;
const_iterator
end
()
const
;
size_t
size
()
const
;
size_t
size
()
const
;
abstract_tuple
*
copy
()
const
;
abstract_tuple
*
copy
()
const
;
...
...
cppa/detail/tuple_vals.hpp
View file @
aa0427cb
...
@@ -61,26 +61,13 @@ class tuple_vals : public abstract_tuple
...
@@ -61,26 +61,13 @@ class tuple_vals : public abstract_tuple
static
types_array
<
ElementTypes
...
>
m_types
;
static
types_array
<
ElementTypes
...
>
m_types
;
type_value_pair
m_view
[
sizeof
...(
ElementTypes
)];
void
init_view
()
{
for
(
size_t
i
=
0
;
i
<
sizeof
...(
ElementTypes
);
++
i
)
{
m_view
[
i
].
first
=
m_types
[
i
];
m_view
[
i
].
second
=
m_data
.
at
(
i
);
}
}
public:
public:
using
abstract_tuple
::
const_iterator
;
tuple_vals
()
:
m_data
()
{
}
tuple_vals
()
:
m_data
()
{
init_view
();
}
tuple_vals
(
tuple_vals
const
&
other
)
:
super
(),
m_data
(
other
.
m_data
)
{
init_view
();
}
tuple_vals
(
tuple_vals
const
&
other
)
:
super
(),
m_data
(
other
.
m_data
)
{
}
tuple_vals
(
ElementTypes
const
&
...
args
)
:
m_data
(
args
...)
{
init_view
();
}
tuple_vals
(
ElementTypes
const
&
...
args
)
:
m_data
(
args
...)
{
}
inline
data_type
const
&
data
()
const
inline
data_type
const
&
data
()
const
{
{
...
@@ -92,16 +79,6 @@ class tuple_vals : public abstract_tuple
...
@@ -92,16 +79,6 @@ class tuple_vals : public abstract_tuple
return
m_data
;
return
m_data
;
}
}
const_iterator
begin
()
const
{
return
m_view
;
}
const_iterator
end
()
const
{
return
begin
()
+
sizeof
...(
ElementTypes
);
}
size_t
size
()
const
size_t
size
()
const
{
{
return
sizeof
...(
ElementTypes
);
return
sizeof
...(
ElementTypes
);
...
@@ -115,14 +92,12 @@ class tuple_vals : public abstract_tuple
...
@@ -115,14 +92,12 @@ class tuple_vals : public abstract_tuple
void
const
*
at
(
size_t
pos
)
const
void
const
*
at
(
size_t
pos
)
const
{
{
CPPA_REQUIRE
(
pos
<
size
());
CPPA_REQUIRE
(
pos
<
size
());
return
m_
view
[
pos
].
second
;
return
m_
data
.
at
(
pos
)
;
}
}
void
*
mutable_at
(
size_t
pos
)
void
*
mutable_at
(
size_t
pos
)
{
{
CPPA_REQUIRE
(
pos
<
size
());
return
const_cast
<
void
*>
(
at
(
pos
));
// safe, because tuple_cals is used in cow_ptrs only
return
const_cast
<
void
*>
(
m_view
[
pos
].
second
);
}
}
uniform_type_info
const
*
type_at
(
size_t
pos
)
const
uniform_type_info
const
*
type_at
(
size_t
pos
)
const
...
...
cppa/invoke_rules.hpp
View file @
aa0427cb
...
@@ -50,7 +50,6 @@ namespace cppa {
...
@@ -50,7 +50,6 @@ namespace cppa {
class
any_tuple
;
class
any_tuple
;
class
invoke_rules
;
class
invoke_rules
;
class
any_tuple_view
;
class
timed_invoke_rules
;
class
timed_invoke_rules
;
typedef
std
::
list
<
detail
::
invokable_ptr
>
invokable_list
;
typedef
std
::
list
<
detail
::
invokable_ptr
>
invokable_list
;
...
@@ -88,8 +87,6 @@ class invoke_rules_base
...
@@ -88,8 +87,6 @@ class invoke_rules_base
*/
*/
bool
operator
()(
any_tuple
const
&
data
)
const
;
bool
operator
()(
any_tuple
const
&
data
)
const
;
bool
operator
()(
any_tuple_view
const
&
data
)
const
;
/**
/**
* @brief Tries to match @p data with one of the stored patterns.
* @brief Tries to match @p data with one of the stored patterns.
* @param data Data tuple that should be matched.
* @param data Data tuple that should be matched.
...
...
cppa/match.hpp
View file @
aa0427cb
...
@@ -35,7 +35,6 @@
...
@@ -35,7 +35,6 @@
#include "cppa/tuple.hpp"
#include "cppa/tuple.hpp"
#include "cppa/invoke_rules.hpp"
#include "cppa/invoke_rules.hpp"
#include "cppa/any_tuple_view.hpp"
#include "cppa/util/if_else.hpp"
#include "cppa/util/if_else.hpp"
#include "cppa/util/enable_if.hpp"
#include "cppa/util/enable_if.hpp"
...
@@ -49,14 +48,16 @@ namespace detail {
...
@@ -49,14 +48,16 @@ namespace detail {
template
<
typename
Tuple
>
template
<
typename
Tuple
>
struct
match_helper
struct
match_helper
{
{
static
constexpr
bool
is_view
=
std
::
is_same
<
Tuple
,
any_tuple_view
>::
value
;
//static constexpr bool is_view = std::is_same<Tuple, any_tuple_view>::value;
static
constexpr
bool
is_view
=
false
;
Tuple
what
;
Tuple
what
;
template
<
typename
T
>
template
<
typename
T
>
match_helper
(
T
const
&
w
,
typename
util
::
enable_if_c
<
std
::
is_same
<
T
,
T
>::
value
&&
is_view
>::
type
*
=
0
)
match_helper
(
T
const
&
w
,
typename
util
::
enable_if_c
<
std
::
is_same
<
T
,
T
>::
value
&&
is_view
>::
type
*
=
0
)
:
what
(
w
)
{
}
:
what
(
w
)
{
}
template
<
typename
T
>
match_helper
(
T
const
&
w
,
typename
util
::
enable_if_c
<
std
::
is_same
<
T
,
T
>::
value
&&
!
is_view
>::
type
*
=
0
)
//template<typename T>
:
what
(
make_tuple
(
w
))
{
}
//match_helper(T const& w, typename util::enable_if_c<std::is_same<T, T>::value && !is_view>::type* =0)
// : what(make_tuple(w)) { }
void
operator
()(
invoke_rules
&
rules
)
{
rules
(
what
);
}
void
operator
()(
invoke_rules
&
rules
)
{
rules
(
what
);
}
void
operator
()(
invoke_rules
&&
rules
)
{
rules
(
what
);
}
void
operator
()(
invoke_rules
&&
rules
)
{
rules
(
what
);
}
template
<
typename
Head
,
typename
...
Tail
>
template
<
typename
Head
,
typename
...
Tail
>
...
@@ -76,6 +77,7 @@ struct match_helper
...
@@ -76,6 +77,7 @@ struct match_helper
}
// namespace detail
}
// namespace detail
/*
template<typename T>
template<typename T>
auto match(T const& x)
auto match(T const& x)
-> detail::match_helper<
-> detail::match_helper<
...
@@ -86,6 +88,7 @@ auto match(T const& x)
...
@@ -86,6 +88,7 @@ auto match(T const& x)
{
{
return {x};
return {x};
}
}
*/
}
// namespace cppa
}
// namespace cppa
...
...
cppa/pattern.hpp
View file @
aa0427cb
...
@@ -84,7 +84,50 @@ class pattern
...
@@ -84,7 +84,50 @@ class pattern
typedef
util
::
fixed_vector
<
size_t
,
filtered_types
::
size
>
mapping_vector
;
typedef
util
::
fixed_vector
<
size_t
,
filtered_types
::
size
>
mapping_vector
;
typedef
type_value_pair
const
*
const_iterator
;
class
const_iterator
{
type_value_pair
const
*
iter
;
public:
const_iterator
(
type_value_pair
const
*
i
)
:
iter
(
i
)
{
}
const_iterator
(
const_iterator
const
&
)
=
default
;
inline
uniform_type_info
const
*
type
()
const
{
return
iter
->
first
;
}
inline
void
const
*
value
()
const
{
return
iter
->
second
;
}
inline
decltype
(
iter
)
operator
->
()
{
return
iter
;
}
inline
decltype
(
*
iter
)
operator
*
()
{
return
*
iter
;
}
inline
const_iterator
&
operator
++
()
{
++
iter
;
return
*
this
;
}
inline
const_iterator
&
operator
--
()
{
--
iter
;
return
*
this
;
}
inline
bool
operator
==
(
const_iterator
const
&
other
)
const
{
return
iter
==
other
.
iter
;
}
inline
bool
operator
!=
(
const_iterator
const
&
other
)
const
{
return
iter
!=
other
.
iter
;
}
};
//typedef type_value_pair const* const_iterator;
const_iterator
begin
()
const
{
return
m_ptrs
;
}
const_iterator
begin
()
const
{
return
m_ptrs
;
}
...
...
cppa/tuple_cast.hpp
View file @
aa0427cb
...
@@ -36,7 +36,6 @@
...
@@ -36,7 +36,6 @@
#include "cppa/option.hpp"
#include "cppa/option.hpp"
#include "cppa/pattern.hpp"
#include "cppa/pattern.hpp"
#include "cppa/any_tuple.hpp"
#include "cppa/any_tuple.hpp"
#include "cppa/any_tuple_view.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/detail/matches.hpp"
#include "cppa/detail/matches.hpp"
#include "cppa/detail/types_array.hpp"
#include "cppa/detail/types_array.hpp"
...
@@ -125,6 +124,7 @@ auto tuple_cast(any_tuple const& tup)
...
@@ -125,6 +124,7 @@ auto tuple_cast(any_tuple const& tup)
return
tuple_cast_impl
<
tuple_type
,
any_tuple
,
T
...
>
(
tup
);
return
tuple_cast_impl
<
tuple_type
,
any_tuple
,
T
...
>
(
tup
);
}
}
/*
template<typename... P>
template<typename... P>
auto tuple_cast(any_tuple_view const& tup, pattern<P...> const& p)
auto tuple_cast(any_tuple_view const& tup, pattern<P...> const& p)
-> option<
-> option<
...
@@ -152,6 +152,7 @@ auto tuple_cast(any_tuple_view const& tup)
...
@@ -152,6 +152,7 @@ auto tuple_cast(any_tuple_view const& tup)
typedef typename result_type::value_type tuple_type;
typedef typename result_type::value_type tuple_type;
return tuple_cast_impl<tuple_type, any_tuple_view, T...>(tup);
return tuple_cast_impl<tuple_type, any_tuple_view, T...>(tup);
}
}
*/
}
// namespace cppa
}
// namespace cppa
...
...
src/empty_tuple.cpp
View file @
aa0427cb
...
@@ -33,16 +33,6 @@
...
@@ -33,16 +33,6 @@
namespace
cppa
{
namespace
detail
{
namespace
cppa
{
namespace
detail
{
abstract_tuple
::
const_iterator
empty_tuple
::
begin
()
const
{
return
nullptr
;
}
abstract_tuple
::
const_iterator
empty_tuple
::
end
()
const
{
return
nullptr
;
}
size_t
empty_tuple
::
size
()
const
size_t
empty_tuple
::
size
()
const
{
{
return
0
;
return
0
;
...
...
src/invoke_rules.cpp
View file @
aa0427cb
...
@@ -55,15 +55,6 @@ bool invoke_rules_base::operator()(const any_tuple& data) const
...
@@ -55,15 +55,6 @@ bool invoke_rules_base::operator()(const any_tuple& data) const
return
false
;
return
false
;
}
}
bool
invoke_rules_base
::
operator
()(
any_tuple_view
const
&
data
)
const
{
for
(
detail
::
invokable_ptr
const
&
ptr
:
m_list
)
{
if
(
ptr
->
invoke
(
data
))
return
true
;
}
return
false
;
}
detail
::
intermediate
*
detail
::
intermediate
*
invoke_rules_base
::
get_intermediate
(
const
any_tuple
&
t
)
const
invoke_rules_base
::
get_intermediate
(
const
any_tuple
&
t
)
const
{
{
...
...
src/object_array.cpp
View file @
aa0427cb
...
@@ -49,15 +49,11 @@ object_array::object_array(object_array const& other)
...
@@ -49,15 +49,11 @@ object_array::object_array(object_array const& other)
void
object_array
::
push_back
(
object
const
&
what
)
void
object_array
::
push_back
(
object
const
&
what
)
{
{
m_elements
.
push_back
(
what
);
m_elements
.
push_back
(
what
);
auto
&
back
=
m_elements
.
back
();
m_data
.
push_back
({
back
.
type
(),
back
.
value
()});
}
}
void
object_array
::
push_back
(
object
&&
what
)
void
object_array
::
push_back
(
object
&&
what
)
{
{
m_elements
.
push_back
(
std
::
move
(
what
));
m_elements
.
push_back
(
std
::
move
(
what
));
auto
&
back
=
m_elements
.
back
();
m_data
.
push_back
({
back
.
type
(),
back
.
value
()});
}
}
void
*
object_array
::
mutable_at
(
size_t
pos
)
void
*
object_array
::
mutable_at
(
size_t
pos
)
...
@@ -80,16 +76,6 @@ void const* object_array::at(size_t pos) const
...
@@ -80,16 +76,6 @@ void const* object_array::at(size_t pos) const
return
m_elements
[
pos
].
value
();
return
m_elements
[
pos
].
value
();
}
}
abstract_tuple
::
const_iterator
object_array
::
begin
()
const
{
return
m_data
.
data
();
}
abstract_tuple
::
const_iterator
object_array
::
end
()
const
{
return
begin
()
+
m_data
.
size
();
}
bool
object_array
::
equals
(
cppa
::
detail
::
abstract_tuple
const
&
ut
)
const
bool
object_array
::
equals
(
cppa
::
detail
::
abstract_tuple
const
&
ut
)
const
{
{
if
(
size
()
==
ut
.
size
())
if
(
size
()
==
ut
.
size
())
...
...
unit_testing/test__tuple.cpp
View file @
aa0427cb
...
@@ -42,6 +42,7 @@ size_t test__tuple()
...
@@ -42,6 +42,7 @@ size_t test__tuple()
// get a view of t0
// get a view of t0
any_tuple
atup0
(
t0
);
any_tuple
atup0
(
t0
);
CPPA_CHECK
(
atup0
.
size
()
==
2
&&
atup0
.
at
(
0
)
==
&
get
<
0
>
(
t0
));
CPPA_CHECK
(
atup0
.
size
()
==
2
&&
atup0
.
at
(
0
)
==
&
get
<
0
>
(
t0
));
/*
auto v1opt = tuple_cast<std::string, anything>(any_tuple_view(atup0));
auto v1opt = tuple_cast<std::string, anything>(any_tuple_view(atup0));
// the tuple_view forces atup0 to detach from t0
// the tuple_view forces atup0 to detach from t0
CPPA_CHECK(atup0.size() == 2 && atup0.at(0) != &get<0>(t0));
CPPA_CHECK(atup0.size() == 2 && atup0.at(0) != &get<0>(t0));
...
@@ -55,6 +56,7 @@ size_t test__tuple()
...
@@ -55,6 +56,7 @@ size_t test__tuple()
CPPA_CHECK_EQUAL(v1_0, "1");
CPPA_CHECK_EQUAL(v1_0, "1");
CPPA_CHECK_EQUAL(atup0.at(0), &(get<0>(v1))); // point to the same
CPPA_CHECK_EQUAL(atup0.at(0), &(get<0>(v1))); // point to the same
}
}
*/
// use tuple cast to get a subtuple
// use tuple cast to get a subtuple
any_tuple
at0
(
t0
);
any_tuple
at0
(
t0
);
auto
v0opt
=
tuple_cast
<
std
::
string
,
anything
>
(
at0
);
auto
v0opt
=
tuple_cast
<
std
::
string
,
anything
>
(
at0
);
...
...
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