28 #ifndef VC_COMMON_ALGORITHMS_H_ 29 #define VC_COMMON_ALGORITHMS_H_ 33 namespace Vc_VERSIONED_NAMESPACE
48 constexpr
bool all_of(
bool b) {
return b; }
57 constexpr
bool any_of(
bool b) {
return b; }
66 constexpr
bool none_of(
bool b) {
return !b; }
76 constexpr
bool some_of(
bool) {
return false; }
107 template <
class InputIt,
class UnaryFunction>
108 UnaryFunction
simd_for_each(InputIt first, InputIt last, UnaryFunction f);
110 template <
class InputIt,
class UnaryFunction,
111 class ValueType =
typename std::iterator_traits<InputIt>::value_type>
113 Traits::is_functor_argument_immutable<UnaryFunction, simdize<ValueType>>::value,
119 const auto lastV = last - V::Size + 1;
120 for (; first < lastV; first += V::Size) {
122 load_interleaved(tmp, std::addressof(*first));
125 for (; first != last; ++first) {
127 load_interleaved(tmp, std::addressof(*first));
133 template <
typename InputIt,
typename UnaryFunction,
134 class ValueType =
typename std::iterator_traits<InputIt>::value_type>
136 !Traits::is_functor_argument_immutable<UnaryFunction, simdize<ValueType>>::value,
142 const auto lastV = last - V::size() + 1;
143 for (; first < lastV; first += V::size()) {
145 load_interleaved(tmp, std::addressof(*first));
147 store_interleaved(tmp, std::addressof(*first));
149 for (; first != last; ++first) {
151 load_interleaved(tmp, std::addressof(*first));
153 store_interleaved(tmp, std::addressof(*first));
160 template <
typename InputIt,
typename UnaryFunction,
161 class ValueType =
typename std::iterator_traits<InputIt>::value_type>
163 Traits::is_functor_argument_immutable<UnaryFunction, simdize<ValueType>>::value,
165 simd_for_each_n(InputIt first, std::size_t count, UnaryFunction f)
167 typename std::make_signed<size_t>::type len = count;
170 for (; len >= int(V::size()); len -= V::Size, first += V::Size) {
172 load_interleaved(tmp, std::addressof(*first));
175 for (; len != 0; --len, ++first) {
177 load_interleaved(tmp, std::addressof(*first));
183 template <
typename InputIt,
typename UnaryFunction,
184 class ValueType =
typename std::iterator_traits<InputIt>::value_type>
186 !Traits::is_functor_argument_immutable<UnaryFunction, simdize<ValueType>>::value,
188 simd_for_each_n(InputIt first, std::size_t count, UnaryFunction f)
190 typename std::make_signed<size_t>::type len = count;
193 for (; len >= int(V::size()); len -= V::Size, first += V::Size) {
195 load_interleaved(tmp, std::addressof(*first));
197 store_interleaved(tmp, std::addressof(*first));
199 for (; len != 0; --len, ++first) {
201 load_interleaved(tmp, std::addressof(*first));
203 store_interleaved(tmp, std::addressof(*first));
210 #endif // VC_COMMON_ALGORITHMS_H_ constexpr bool any_of(bool b)
Returns b.
SimdizeDetail::simdize< T, N, MT > simdize
UnaryFunction simd_for_each(InputIt first, InputIt last, UnaryFunction f)
Vc variant of the std::for_each algorithm.
bool isFull() const
Returns a logical AND of all components.
constexpr bool none_of(bool b)
Returns !b.
constexpr bool all_of(bool b)
Returns b.
constexpr bool some_of(bool)
Returns false.
The main SIMD mask class.
bool isNotEmpty() const
Returns a logical OR of all components.
bool isEmpty() const
Returns true if components are false, false otherwise.
bool isMix() const
Returns !isFull() && !isEmpty().