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
7fd6146d
Commit
7fd6146d
authored
Mar 05, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
forced_tuple_cast
parent
8b5d6409
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
cppa/detail/tuple_cast_impl.hpp
cppa/detail/tuple_cast_impl.hpp
+37
-0
No files found.
cppa/detail/tuple_cast_impl.hpp
View file @
7fd6146d
...
...
@@ -98,6 +98,27 @@ struct tuple_cast_impl
}
return
{};
}
template
<
class
Tuple
>
static
inline
Result
force
(
Tuple
const
&
tup
,
pattern
<
T
...
>
const
&
p
)
{
mapping_vector
mv
;
if
(
WP
==
wildcard_position
::
in_between
)
{
// first range
mv
.
resize
(
size
);
auto
begin
=
mv
.
begin
();
std
::
iota
(
begin
,
begin
+
first_wc
,
0
);
// second range
begin
=
mv
.
begin
()
+
first_wc
;
std
::
iota
(
begin
,
mv
.
end
(),
tup
.
size
()
-
(
size
-
first_wc
));
return
{
Result
::
from
(
tup
.
vals
(),
mv
)};
}
else
{
match
(
tup
,
p
,
mv
);
return
{
Result
::
from
(
tup
.
vals
(),
mv
)};
}
}
};
template
<
class
Result
,
typename
...
T
>
...
...
@@ -125,6 +146,11 @@ struct tuple_cast_impl<wildcard_position::nil, Result, T...>
}
return
{};
}
template
<
class
Tuple
>
static
inline
Result
force
(
Tuple
const
&
tup
,
pattern
<
T
...
>
const
&
)
{
return
{
Result
::
from
(
tup
.
vals
())};
}
};
template
<
class
Result
,
typename
...
T
>
...
...
@@ -141,6 +167,11 @@ struct tuple_cast_impl<wildcard_position::trailing, Result, T...>
}
return
{};
}
template
<
class
Tuple
>
static
inline
Result
force
(
Tuple
const
&
tup
,
pattern
<
T
...
>
const
&
)
{
return
{
Result
::
from
(
tup
.
vals
())};
}
};
template
<
class
Result
,
typename
...
T
>
...
...
@@ -171,6 +202,12 @@ struct tuple_cast_impl<wildcard_position::leading, Result, T...>
}
return
{};
}
template
<
class
Tuple
>
static
inline
Result
force
(
Tuple
const
&
tup
,
pattern
<
T
...
>
const
&
)
{
size_t
o
=
tup
.
size
()
-
(
sizeof
...(
T
)
-
1
);
return
Result
::
offset_subtuple
(
tup
.
vals
(),
o
);
}
};
}
}
...
...
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