Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
phcerdan
VTK-m
Commits
ecb46023
Commit
ecb46023
authored
Jun 21, 2018
by
Sujin Philip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ListTagAppend and ListTagAppendUnique
parent
55eafbaf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
1 deletion
+45
-1
vtkm/ListTag.h
vtkm/ListTag.h
+16
-0
vtkm/internal/ListTagDetail.h
vtkm/internal/ListTagDetail.h
+8
-1
vtkm/testing/UnitTestListTag.cxx
vtkm/testing/UnitTestListTag.cxx
+21
-0
No files found.
vtkm/ListTag.h
View file @
ecb46023
...
...
@@ -73,6 +73,22 @@ struct ListTagJoin : detail::ListRoot
using
list
=
typename
detail
::
ListJoin
<
typename
ListTag1
::
list
,
typename
ListTag2
::
list
>::
type
;
};
/// A tag that is constructed by appending \c Type to \c ListTag.
template
<
typename
ListTag
,
typename
Type
>
struct
ListTagAppend
:
detail
::
ListRoot
{
using
list
=
typename
detail
::
ListJoin
<
typename
ListTag
::
list
,
detail
::
ListBase
<
Type
>>::
type
;
};
/// Append \c Type to \c ListTag only if \c ListTag does not already contain \c Type.
/// No checks are performed to see if \c ListTag itself has only unqiue elements.
template
<
typename
ListTag
,
typename
Type
>
struct
ListTagAppendUnique
:
detail
::
ListRoot
{
using
list
=
typename
detail
::
ListAppendUniqueImpl
<
typename
ListTag
::
list
,
Type
>::
type
;
};
/// A tag that consists of elements that are found in both tags. This struct
/// can be subclassed and still behave like a list tag.
template
<
typename
ListTag1
,
typename
ListTag2
>
...
...
vtkm/internal/ListTagDetail.h
View file @
ecb46023
...
...
@@ -229,7 +229,14 @@ struct ListCrossProductImpl
brigand
::
lazy
::
push_front
<
brigand
::
_1
,
brigand
::
parent
<
brigand
::
_1
>>>>>>>>>>
;
};
//-----------------------------------------------------------------------------
template
<
typename
List
,
typename
Type
>
struct
ListAppendUniqueImpl
{
using
type
=
typename
std
::
conditional
<
ListContainsImpl
<
Type
,
List
>::
value
,
List
,
typename
ListJoin
<
List
,
ListBase
<
Type
>>::
type
>::
type
;
};
}
// namespace detail
...
...
vtkm/testing/UnitTestListTag.cxx
View file @
ecb46023
...
...
@@ -67,6 +67,18 @@ struct TestListTagUniversal : vtkm::ListTagUniversal
{
};
struct
TestListTagAppend
:
vtkm
::
ListTagAppend
<
TestListTag3
,
TestClass
<
34
>>
{
};
struct
TestListTagAppendUnique1
:
vtkm
::
ListTagAppendUnique
<
TestListTag3
,
TestClass
<
32
>>
{
};
struct
TestListTagAppendUnique2
:
vtkm
::
ListTagAppendUnique
<
TestListTagAppendUnique1
,
TestClass
<
34
>>
{
};
template
<
int
N
,
int
M
>
std
::
pair
<
int
,
int
>
test_number
(
brigand
::
list
<
TestClass
<
N
>
,
TestClass
<
M
>>
)
{
...
...
@@ -239,6 +251,15 @@ void TestLists()
TryList
(
vtkm
::
Vec
<
std
::
pair
<
int
,
int
>
,
3
>
({
31
,
11
},
{
32
,
11
},
{
33
,
11
}),
TestListTagCrossProduct
());
std
::
cout
<<
"ListTagAppend"
<<
std
::
endl
;
TryList
(
vtkm
::
Vec
<
int
,
4
>
(
31
,
32
,
33
,
34
),
TestListTagAppend
());
std
::
cout
<<
"ListTagAppendUnique1"
<<
std
::
endl
;
TryList
(
vtkm
::
Vec
<
int
,
3
>
(
31
,
32
,
33
),
TestListTagAppendUnique1
());
std
::
cout
<<
"ListTagAppendUnique2"
<<
std
::
endl
;
TryList
(
vtkm
::
Vec
<
int
,
4
>
(
31
,
32
,
33
,
34
),
TestListTagAppendUnique2
());
std
::
cout
<<
"ListTagUniversal"
<<
std
::
endl
;
...
...
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