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
8e7346fe
Commit
8e7346fe
authored
Feb 09, 2016
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tl_union and tl_intersect
parent
07d5a4af
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
libcaf_core/caf/detail/type_list.hpp
libcaf_core/caf/detail/type_list.hpp
+64
-0
No files found.
libcaf_core/caf/detail/type_list.hpp
View file @
8e7346fe
...
...
@@ -477,6 +477,24 @@ struct tl_count<empty_type_list, Pred> {
template
<
class
List
,
template
<
class
>
class
Pred
>
constexpr
size_t
tl_count
<
List
,
Pred
>::
value
;
// size_t count(type)
/// Counts the number of elements in the list which are equal to `T`.
template
<
class
List
,
class
T
>
struct
tl_count_type
{
static
constexpr
size_t
value
=
(
std
::
is_same
<
typename
tl_head
<
List
>::
type
,
T
>::
value
?
1
:
0
)
+
tl_count_type
<
typename
tl_tail
<
List
>::
type
,
T
>::
value
;
};
template
<
class
T
>
struct
tl_count_type
<
empty_type_list
,
T
>
{
static
constexpr
size_t
value
=
0
;
};
template
<
class
List
,
class
T
>
constexpr
size_t
tl_count_type
<
List
,
T
>::
value
;
// size_t count_not(predicate)
/// Counts the number of elements in the list which satisfy a predicate.
...
...
@@ -876,6 +894,52 @@ struct tl_trim<empty_type_list, What> {
using
type
=
empty_type_list
;
};
// list union(list1, list2)
template
<
class
...
Xs
>
struct
tl_union
{
using
type
=
typename
tl_distinct
<
typename
tl_concat
<
Xs
...
>::
type
>::
type
;
};
// list intersect(list1, list2)
template
<
class
List
,
bool
HeadIsUnique
=
tl_count_type
<
List
,
typename
tl_head
<
List
>
::
type
>::
value
==
1
>
struct
tl_intersect_impl
;
template
<
>
struct
tl_intersect_impl
<
empty_type_list
,
false
>
{
using
type
=
empty_type_list
;
};
template
<
class
T0
,
class
...
Ts
>
struct
tl_intersect_impl
<
type_list
<
T0
,
Ts
...
>
,
true
>
{
using
type
=
typename
tl_intersect_impl
<
type_list
<
Ts
...
>>::
type
;
};
template
<
class
T0
,
class
...
Ts
>
struct
tl_intersect_impl
<
type_list
<
T0
,
Ts
...
>
,
false
>
{
using
type
=
typename
tl_concat
<
type_list
<
T0
>
,
typename
tl_intersect_impl
<
typename
tl_filter_type
<
type_list
<
Ts
...
>
,
T0
>::
type
>::
type
>::
type
;
};
template
<
class
...
Ts
>
struct
tl_intersect
{
using
type
=
typename
tl_intersect_impl
<
typename
tl_concat
<
Ts
...
>::
type
>::
type
;
};
// list group_by(list, predicate)
template
<
bool
Append
,
class
What
,
class
Where
>
...
...
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