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
408022cf
Commit
408022cf
authored
Jan 18, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apply_tuple
parent
c1d882fb
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
25 additions
and
152 deletions
+25
-152
Makefile.am
Makefile.am
+0
-1
cppa.files
cppa.files
+0
-1
cppa/any_tuple.hpp
cppa/any_tuple.hpp
+0
-1
cppa/cppa.hpp
cppa/cppa.hpp
+0
-1
cppa/detail/get_behavior.hpp
cppa/detail/get_behavior.hpp
+4
-3
cppa/detail/invokable.hpp
cppa/detail/invokable.hpp
+4
-4
cppa/invoke.hpp
cppa/invoke.hpp
+0
-134
cppa/on.hpp
cppa/on.hpp
+1
-1
cppa/util/apply_tuple.hpp
cppa/util/apply_tuple.hpp
+16
-4
src/invoke_rules.cpp
src/invoke_rules.cpp
+0
-1
unit_testing/test__tuple.cpp
unit_testing/test__tuple.cpp
+0
-1
No files found.
Makefile.am
View file @
408022cf
...
...
@@ -148,7 +148,6 @@ nobase_library_include_HEADERS = \
cppa/get_view.hpp
\
cppa/group.hpp
\
cppa/intrusive_ptr.hpp
\
cppa/invoke.hpp
\
cppa/invoke_rules.hpp
\
cppa/object.hpp
\
cppa/on.hpp
\
...
...
cppa.files
View file @
408022cf
...
...
@@ -35,7 +35,6 @@ cppa/util/has_copy_member_fun.hpp
cppa/detail/intermediate.hpp
cppa/detail/invokable.hpp
cppa/invoke_rules.hpp
cppa/invoke.hpp
cppa/on.hpp
unit_testing/test__serialization.cpp
cppa/serializer.hpp
...
...
cppa/any_tuple.hpp
View file @
408022cf
...
...
@@ -34,7 +34,6 @@
#include "cppa/cow_ptr.hpp"
#include "cppa/tuple.hpp"
#include "cppa/tuple_view.hpp"
#include "cppa/detail/abstract_tuple.hpp"
namespace
cppa
{
...
...
cppa/cppa.hpp
View file @
408022cf
...
...
@@ -40,7 +40,6 @@
#include "cppa/self.hpp"
#include "cppa/tuple.hpp"
#include "cppa/actor.hpp"
#include "cppa/invoke.hpp"
#include "cppa/channel.hpp"
#include "cppa/receive.hpp"
#include "cppa/announce.hpp"
...
...
cppa/detail/get_behavior.hpp
View file @
408022cf
...
...
@@ -33,8 +33,9 @@
#include <type_traits>
#include "cppa/invoke.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/apply_tuple.hpp"
#include "cppa/detail/tdata.hpp"
#include "cppa/scheduled_actor.hpp"
...
...
@@ -74,7 +75,7 @@ class ftor_behavior<true, true, F, Args...> : public scheduled_actor
ftor_behavior
(
F
ptr
,
Args
const
&
...
args
)
:
m_fun
(
ptr
),
m_args
(
args
...)
{
}
virtual
void
act
()
{
invok
e
(
m_fun
,
m_args
);
}
virtual
void
act
()
{
util
::
apply_tupl
e
(
m_fun
,
m_args
);
}
};
...
...
@@ -120,7 +121,7 @@ class ftor_behavior<false, true, F, Args...> : public scheduled_actor
{
}
virtual
void
act
()
{
invok
e
(
m_fun
,
m_args
);
}
virtual
void
act
()
{
util
::
apply_tupl
e
(
m_fun
,
m_args
);
}
};
...
...
cppa/detail/invokable.hpp
View file @
408022cf
...
...
@@ -35,9 +35,9 @@
#include <cstddef>
#include <cstdint>
#include "cppa/invoke.hpp"
#include "cppa/any_tuple.hpp"
#include "cppa/util/duration.hpp"
#include "cppa/util/apply_tuple.hpp"
#include "cppa/util/fixed_vector.hpp"
#include "cppa/detail/matches.hpp"
...
...
@@ -131,7 +131,7 @@ class invokable_impl : public invokable
void
invoke
()
// override
{
cppa
::
invok
e
(
m_target
,
m_args
);
util
::
apply_tupl
e
(
m_target
,
m_args
);
}
};
...
...
@@ -156,13 +156,13 @@ class invokable_impl : public invokable
{
// "perfect" match; no mapping needed at all
TupleView
tv
=
TupleView
::
from
(
data
.
vals
());
cppa
::
invok
e
(
m_iimpl
.
m_target
,
tv
);
util
::
apply_tupl
e
(
m_iimpl
.
m_target
,
tv
);
}
else
{
// mapping needed
TupleView
tv
(
data
.
vals
(),
mv
);
cppa
::
invok
e
(
m_iimpl
.
m_target
,
tv
);
util
::
apply_tupl
e
(
m_iimpl
.
m_target
,
tv
);
}
return
true
;
}
...
...
cppa/invoke.hpp
deleted
100644 → 0
View file @
c1d882fb
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \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 INVOKE_HPP
#define INVOKE_HPP
#include <type_traits>
#include "cppa/get.hpp"
#include "cppa/tuple.hpp"
#include "cppa/any_tuple.hpp"
#include "cppa/tuple_view.hpp"
#include "cppa/util/at.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/element_at.hpp"
#include "cppa/util/callable_trait.hpp"
//#include "cppa/util/reverse_type_list.hpp"
namespace
cppa
{
namespace
detail
{
template
<
size_t
N
,
typename
F
,
typename
ResultType
,
class
Tuple
,
typename
ArgTypeList
,
typename
...
Args
>
struct
invoke_helper
{
//typedef typename util::reverse_type_list<ArgTypeList>::type rlist;
typedef
typename
ArgTypeList
::
back
back
;
typedef
typename
util
::
element_at
<
N
,
Tuple
>::
type
tuple_val_type
;
typedef
typename
util
::
tl_pop_back
<
ArgTypeList
>::
type
next_list
;
inline
static
ResultType
_
(
F
&
f
,
Tuple
const
&
t
,
Args
const
&
...
args
)
{
static_assert
(
std
::
is_convertible
<
tuple_val_type
,
back
>::
value
,
"tuple element is not convertible to expected argument"
);
return
invoke_helper
<
N
-
1
,
F
,
ResultType
,
Tuple
,
next_list
,
tuple_val_type
,
Args
...
>
::
_
(
f
,
t
,
get
<
N
>
(
t
),
args
...);
}
};
template
<
size_t
N
,
typename
F
,
typename
ResultType
,
class
Tuple
,
typename
...
Args
>
struct
invoke_helper
<
N
,
F
,
ResultType
,
Tuple
,
util
::
type_list
<>
,
Args
...
>
{
inline
static
ResultType
_
(
F
&
f
,
Tuple
const
&
,
Args
const
&
...
args
)
{
return
f
(
args
...);
}
};
template
<
bool
HasCallableTrait
,
typename
F
,
class
Tuple
>
struct
invoke_impl
;
template
<
typename
F
,
template
<
typename
...
>
class
Tuple
,
typename
...
TTypes
>
struct
invoke_impl
<
true
,
F
,
Tuple
<
TTypes
...
>
>
{
static_assert
(
sizeof
...(
TTypes
)
>
0
,
"empty tuple type"
);
typedef
util
::
callable_trait
<
F
>
trait
;
typedef
typename
trait
::
arg_types
arg_types
;
typedef
typename
trait
::
result_type
result_type
;
typedef
Tuple
<
TTypes
...
>
tuple_type
;
inline
static
result_type
_
(
F
&
f
,
tuple_type
const
&
t
)
{
return
invoke_helper
<
sizeof
...(
TTypes
)
-
1
,
F
,
result_type
,
tuple_type
,
arg_types
>::
_
(
f
,
t
);
}
};
template
<
typename
F
,
template
<
typename
...
>
class
Tuple
,
typename
...
TTypes
>
struct
invoke_impl
<
false
,
F
,
Tuple
<
TTypes
...
>
>
{
static_assert
(
sizeof
...(
TTypes
)
>
0
,
"empty tuple type"
);
typedef
util
::
callable_trait
<
decltype
(
&
F
::
operator
())
>
trait
;
typedef
typename
trait
::
arg_types
arg_types
;
typedef
typename
trait
::
result_type
result_type
;
typedef
Tuple
<
TTypes
...
>
tuple_type
;
inline
static
result_type
_
(
F
&
f
,
tuple_type
const
&
t
)
{
return
invoke_helper
<
sizeof
...(
TTypes
)
-
1
,
F
,
result_type
,
tuple_type
,
arg_types
>::
_
(
f
,
t
);
}
};
}
}
// namespace cppa::detail
namespace
cppa
{
template
<
typename
F
,
class
Tuple
>
typename
detail
::
invoke_impl
<
std
::
is_function
<
typename
std
::
remove_pointer
<
F
>::
type
>::
value
,
F
,
Tuple
>::
result_type
invoke
(
F
what
,
Tuple
const
&
args
)
{
typedef
typename
std
::
remove_pointer
<
F
>::
type
f_type
;
static
constexpr
bool
is_fun
=
std
::
is_function
<
f_type
>::
value
;
return
detail
::
invoke_impl
<
is_fun
,
F
,
Tuple
>::
_
(
what
,
args
);
}
}
// namespace cppa
#endif // INVOKE_HPP
cppa/on.hpp
View file @
408022cf
...
...
@@ -35,10 +35,10 @@
#include <memory>
#include "cppa/atom.hpp"
#include "cppa/invoke.hpp"
#include "cppa/pattern.hpp"
#include "cppa/anything.hpp"
#include "cppa/any_tuple.hpp"
#include "cppa/tuple_view.hpp"
#include "cppa/invoke_rules.hpp"
#include "cppa/util/duration.hpp"
...
...
cppa/util/apply_tuple.hpp
View file @
408022cf
...
...
@@ -67,6 +67,16 @@ struct apply_tuple_util<X, X, Args...> : apply_tuple_impl<X, Args...>
{
};
template
<
>
struct
apply_tuple_util
<
1
,
0
>
{
template
<
typename
F
,
class
Unused
>
static
auto
apply
(
F
&&
f
,
Unused
const
&
)
->
typename
get_result_type
<
F
>::
type
{
return
f
();
}
};
template
<
typename
F
,
template
<
typename
...
>
class
Tuple
,
typename
...
T
>
auto
apply_tuple
(
F
&&
fun
,
Tuple
<
T
...
>&
tup
)
->
typename
get_result_type
<
F
>::
type
...
...
@@ -75,8 +85,9 @@ auto apply_tuple(F&& fun, Tuple<T...>& tup)
static
constexpr
size_t
tup_size
=
sizeof
...(
T
);
static_assert
(
tup_size
>=
fun_args
::
size
,
"cannot conjure up additional arguments"
);
static
constexpr
size_t
from
=
tup_size
-
fun_args
::
size
;
static
constexpr
size_t
to
=
tup_size
-
1
;
static
constexpr
size_t
args_size
=
fun_args
::
size
;
static
constexpr
size_t
from
=
(
args_size
>
0
)
?
tup_size
-
args_size
:
1
;
static
constexpr
size_t
to
=
(
args_size
>
0
)
?
tup_size
-
1
:
0
;
return
apply_tuple_util
<
from
,
to
>::
apply
(
std
::
forward
<
F
>
(
fun
),
tup
);
}
...
...
@@ -88,8 +99,9 @@ auto apply_tuple(F&& fun, Tuple<T...> const& tup)
static
constexpr
size_t
tup_size
=
sizeof
...(
T
);
static_assert
(
tup_size
>=
fun_args
::
size
,
"cannot conjure up additional arguments"
);
static
constexpr
size_t
from
=
tup_size
-
fun_args
::
size
;
static
constexpr
size_t
to
=
tup_size
-
1
;
static
constexpr
size_t
args_size
=
fun_args
::
size
;
static
constexpr
size_t
from
=
(
args_size
>
0
)
?
tup_size
-
args_size
:
1
;
static
constexpr
size_t
to
=
(
args_size
>
0
)
?
tup_size
-
1
:
0
;
return
apply_tuple_util
<
from
,
to
>::
apply
(
std
::
forward
<
F
>
(
fun
),
tup
);
}
...
...
src/invoke_rules.cpp
View file @
408022cf
...
...
@@ -28,7 +28,6 @@
\******************************************************************************/
#include "cppa/invoke.hpp"
#include "cppa/invoke_rules.hpp"
#include "cppa/util/duration.hpp"
#include "cppa/detail/invokable.hpp"
...
...
unit_testing/test__tuple.cpp
View file @
408022cf
...
...
@@ -11,7 +11,6 @@
#include "cppa/on.hpp"
#include "cppa/util.hpp"
#include "cppa/tuple.hpp"
#include "cppa/invoke.hpp"
#include "cppa/get_view.hpp"
#include "cppa/any_tuple.hpp"
#include "cppa/to_string.hpp"
...
...
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