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>
80 inline enable_if<std::is_arithmetic<typename InputIt::value_type>::value &&
81 Traits::is_functor_argument_immutable<
84 simd_for_each(InputIt first, InputIt last, UnaryFunction f)
87 typedef Scalar::Vector<typename InputIt::value_type> V1;
88 for (;
reinterpret_cast<std::uintptr_t
>(std::addressof(*first)) &
94 const auto lastV = last - (V::Size + 1);
95 for (; first < lastV; first += V::Size) {
98 for (; first != last; ++first) {
104 template <
typename InputIt,
typename UnaryFunction>
105 inline enable_if<std::is_arithmetic<typename InputIt::value_type>::value &&
106 !Traits::is_functor_argument_immutable<
109 simd_for_each(InputIt first, InputIt last, UnaryFunction f)
112 typedef Scalar::Vector<typename InputIt::value_type> V1;
113 for (;
reinterpret_cast<std::uintptr_t
>(std::addressof(*first)) &
121 const auto lastV = last - (V::Size + 1);
122 for (; first < lastV; first += V::Size) {
127 for (; first != last; ++first) {
135 template <
typename InputIt,
typename UnaryFunction>
136 inline enable_if<!std::is_arithmetic<typename InputIt::value_type>::value, UnaryFunction>
137 simd_for_each(InputIt first, InputIt last, UnaryFunction f)
139 return std::for_each(first, last, std::move(f));
143 template <
typename InputIt,
typename UnaryFunction>
144 inline enable_if<std::is_arithmetic<typename InputIt::value_type>::value &&
145 Traits::is_functor_argument_immutable<
148 simd_for_each_n(InputIt first, std::size_t count, UnaryFunction f)
150 typename std::make_signed<size_t>::type len = count;
152 typedef Scalar::Vector<typename InputIt::value_type> V1;
153 for (;
reinterpret_cast<std::uintptr_t
>(std::addressof(*first)) &
159 for (; len >= int(V::Size); len -= V::Size, first += V::Size) {
162 for (; len != 0; --len, ++first) {
168 template <
typename InputIt,
typename UnaryFunction>
169 inline enable_if<std::is_arithmetic<typename InputIt::value_type>::value &&
170 !Traits::is_functor_argument_immutable<
173 simd_for_each_n(InputIt first, std::size_t count, UnaryFunction f)
175 typename std::make_signed<size_t>::type len = count;
177 typedef Scalar::Vector<typename InputIt::value_type> V1;
178 for (;
reinterpret_cast<std::uintptr_t
>(std::addressof(*first)) &
186 for (; len >= int(V::Size); len -= V::Size, first += V::Size) {
191 for (; len != 0; --len, ++first) {
200 template <
typename InputIt,
typename UnaryFunction>
201 inline enable_if<!std::is_arithmetic<typename InputIt::value_type>::value, UnaryFunction>
202 simd_for_each_n(InputIt first, std::size_t count, UnaryFunction f)
204 return std::for_each_n(first, count, std::move(f));
210 #endif // VC_COMMON_ALGORITHMS_H_ The main vector class for expressing data parallelism.
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().