Skip to content

Commit

Permalink
Implemented #182, i.e. GCC specific workaround for std::for_each_n.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Westerhout authored and mattkretz committed Jan 30, 2018
1 parent 13ab654 commit b8835e1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions common/algorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,18 @@ simd_for_each_n(InputIt first, std::size_t count, UnaryFunction f)
}

#ifdef Vc_CXX17
#ifdef Vc_GCC
// GCC specific workaround because stdlibc++ doesn't have
// std::for_each_n implemented yet.
template <typename InputIt, typename UnaryFunction>
inline enable_if<!std::is_arithmetic<typename InputIt::value_type>::value, UnaryFunction>
simd_for_each_n(InputIt first, std::size_t count, UnaryFunction f)
{
for (std::size_t i = 0; i < count; ++i, static_cast<void>(++first))
std::apply(f, *first);
return first;
}
#else
template <typename InputIt, typename UnaryFunction>
inline enable_if<
!std::is_arithmetic<typename std::iterator_traits<InputIt>::value_type>::value,
Expand All @@ -216,6 +228,7 @@ simd_for_each_n(InputIt first, std::size_t count, UnaryFunction f)
return std::for_each_n(first, count, std::move(f));
}
#endif
#endif

} // namespace Vc

Expand Down

0 comments on commit b8835e1

Please sign in to comment.