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; }
79 template <
typename InputIt,
typename UnaryFunction>
81 std::is_arithmetic<typename std::iterator_traits<InputIt>::value_type>::value &&
82 Traits::is_functor_argument_immutable<
84 Vector<typename std::iterator_traits<InputIt>::value_type>>::value,
86 simd_for_each(InputIt first, InputIt last, UnaryFunction f)
88 typedef Vector<typename std::iterator_traits<InputIt>::value_type> V;
89 typedef Scalar::Vector<typename std::iterator_traits<InputIt>::value_type> V1;
90 for (;
reinterpret_cast<std::uintptr_t
>(std::addressof(*first)) &
96 const auto lastV = last - V::Size + 1;
97 for (; first < lastV; first += V::Size) {
100 for (; first != last; ++first) {
106 template <
typename InputIt,
typename UnaryFunction>
108 std::is_arithmetic<typename std::iterator_traits<InputIt>::value_type>::value &&
109 !Traits::is_functor_argument_immutable<
111 Vector<typename std::iterator_traits<InputIt>::value_type>>::value,
113 simd_for_each(InputIt first, InputIt last, UnaryFunction f)
115 typedef Vector<typename std::iterator_traits<InputIt>::value_type> V;
116 typedef Scalar::Vector<typename std::iterator_traits<InputIt>::value_type> V1;
117 for (;
reinterpret_cast<std::uintptr_t
>(std::addressof(*first)) &
125 const auto lastV = last - V::Size + 1;
126 for (; first < lastV; first += V::Size) {
131 for (; first != last; ++first) {
139 template <
typename InputIt,
typename UnaryFunction>
141 !std::is_arithmetic<typename std::iterator_traits<InputIt>::value_type>::value,
143 simd_for_each(InputIt first, InputIt last, UnaryFunction f)
145 return std::for_each(first, last, std::move(f));
149 template <
typename InputIt,
typename UnaryFunction>
151 std::is_arithmetic<typename std::iterator_traits<InputIt>::value_type>::value &&
152 Traits::is_functor_argument_immutable<
154 Vector<typename std::iterator_traits<InputIt>::value_type>>::value,
156 simd_for_each_n(InputIt first, std::size_t count, UnaryFunction f)
158 typename std::make_signed<size_t>::type len = count;
159 typedef Vector<typename std::iterator_traits<InputIt>::value_type> V;
160 typedef Scalar::Vector<typename std::iterator_traits<InputIt>::value_type> V1;
161 for (;
reinterpret_cast<std::uintptr_t
>(std::addressof(*first)) &
167 for (; len >= int(V::Size); len -= V::Size, first += V::Size) {
170 for (; len != 0; --len, ++first) {
176 template <
typename InputIt,
typename UnaryFunction>
178 std::is_arithmetic<typename std::iterator_traits<InputIt>::value_type>::value &&
179 !Traits::is_functor_argument_immutable<
181 Vector<typename std::iterator_traits<InputIt>::value_type>>::value,
183 simd_for_each_n(InputIt first, std::size_t count, UnaryFunction f)
185 typename std::make_signed<size_t>::type len = count;
186 typedef Vector<typename std::iterator_traits<InputIt>::value_type> V;
187 typedef Scalar::Vector<typename std::iterator_traits<InputIt>::value_type> V1;
188 for (;
reinterpret_cast<std::uintptr_t
>(std::addressof(*first)) &
196 for (; len >= int(V::Size); len -= V::Size, first += V::Size) {
201 for (; len != 0; --len, ++first) {
210 template <
typename InputIt,
typename UnaryFunction>
212 !std::is_arithmetic<typename std::iterator_traits<InputIt>::value_type>::value,
214 simd_for_each_n(InputIt first, std::size_t count, UnaryFunction f)
216 return std::for_each_n(first, count, std::move(f));
222 #endif // VC_COMMON_ALGORITHMS_H_ constexpr bool any_of(bool b)
Returns b.
constexpr bool none_of(bool b)
Returns !b.
constexpr bool all_of(bool b)
Returns b.
bool isEmpty() const
Returns true if components are false, false otherwise.
constexpr AlignedTag Aligned
Use this object for a flags parameter to request aligned loads and stores.
constexpr bool some_of(bool)
Returns false.
The main SIMD mask class.
bool isFull() const
Returns a logical AND of all components.
constexpr std::size_t MemoryAlignment
Specifies the most conservative memory alignment necessary for aligned loads and stores of Vector typ...
bool isNotEmpty() const
Returns a logical OR of all components.
bool isMix() const
Returns !isFull() && !isEmpty().