Commit c5232e99 authored by Robert Maynard's avatar Robert Maynard

Simplify the implementation of vtkm::ForEach

Also by simplifying the implementation we work around a CUDA 9 issue which
when compiling the old version would cause an internal compiler error and
crash compilation.
parent 6069c19f
......@@ -86,17 +86,7 @@ struct ListTagIntersect : detail::ListRoot
/// default instance of that type.
///
template <typename Functor, typename ListTag>
VTKM_CONT void ListForEach(Functor& f, ListTag)
{
VTKM_IS_LIST_TAG(ListTag);
detail::ListForEachImpl(f, typename ListTag::list());
}
/// For each typename represented by the list tag, call the functor with a
/// default instance of that type.
///
template <typename Functor, typename ListTag>
VTKM_CONT void ListForEach(const Functor& f, ListTag)
VTKM_CONT void ListForEach(Functor&& f, ListTag)
{
VTKM_IS_LIST_TAG(ListTag);
detail::ListForEachImpl(f, typename ListTag::list());
......
......@@ -165,72 +165,30 @@ struct ListIntersect<SameListTag, SameListTag>
using type = SameListTag;
};
//-----------------------------------------------------------------------------
template <typename Functor>
VTKM_CONT void ListForEachImpl(const Functor&, brigand::empty_sequence)
{
}
template <typename Functor, typename T1>
VTKM_CONT void ListForEachImpl(const Functor& f, brigand::list<T1>)
{
f(T1());
}
template <typename Functor, typename T1, typename T2>
VTKM_CONT void ListForEachImpl(const Functor& f, brigand::list<T1, T2>)
{
f(T1());
f(T2());
}
template <typename Functor, typename T1, typename T2, typename T3>
VTKM_CONT void ListForEachImpl(const Functor& f, brigand::list<T1, T2, T3>)
{
f(T1());
f(T2());
f(T3());
}
template <typename Functor,
typename T1,
typename T2,
typename T3,
typename T4,
typename... ArgTypes>
VTKM_CONT void ListForEachImpl(const Functor& f, brigand::list<T1, T2, T3, T4, ArgTypes...>)
{
f(T1());
f(T2());
f(T3());
f(T4());
ListForEachImpl(f, brigand::list<ArgTypes...>());
}
template <typename Functor>
VTKM_CONT void ListForEachImpl(Functor&, brigand::empty_sequence)
VTKM_CONT void ListForEachImpl(Functor&&, brigand::empty_sequence)
{
}
template <typename Functor, typename T1>
VTKM_CONT void ListForEachImpl(Functor& f, brigand::list<T1>)
VTKM_CONT void ListForEachImpl(Functor&& f, brigand::list<T1>)
{
f(T1());
f(T1{});
}
template <typename Functor, typename T1, typename T2>
VTKM_CONT void ListForEachImpl(Functor& f, brigand::list<T1, T2>)
VTKM_CONT void ListForEachImpl(Functor&& f, brigand::list<T1, T2>)
{
f(T1());
f(T2());
f(T1{});
f(T2{});
}
template <typename Functor, typename T1, typename T2, typename T3>
VTKM_CONT void ListForEachImpl(Functor& f, brigand::list<T1, T2, T3>)
VTKM_CONT void ListForEachImpl(Functor&& f, brigand::list<T1, T2, T3>)
{
f(T1());
f(T2());
f(T3());
f(T1{});
f(T2{});
f(T3{});
}
template <typename Functor,
......@@ -239,12 +197,12 @@ template <typename Functor,
typename T3,
typename T4,
typename... ArgTypes>
VTKM_CONT void ListForEachImpl(Functor& f, brigand::list<T1, T2, T3, T4, ArgTypes...>)
VTKM_CONT void ListForEachImpl(Functor&& f, brigand::list<T1, T2, T3, T4, ArgTypes...>)
{
f(T1());
f(T2());
f(T3());
f(T4());
f(T1{});
f(T2{});
f(T3{});
f(T4{});
ListForEachImpl(f, brigand::list<ArgTypes...>());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment