You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The library already provides indexed access. Providing a range interface/iterator access would allow the type to be used with all STL functions. Event though it would degrade to doing it element-wise, it would still vastly increase the ergonomics when some specific utility is not directly available for the simd type. It could also pave the way for specializing some STL functions, like std::min_element, instead of providing hmin, addressing #18
Let me know if you think this is a direction worth taking and I can write a PR
Testcase
#include<experimental/simd>
#include<iostream>namespacestdx= std::experimental;
intmain() {
stdx::native_simd<int> a{[](int i) { return2 << (i - 1); }};
for (auto v : a) {
std::cout << v << '\n';
}
}
Actual Results
$ g++ simd-range.cpp && ./a.out
simd-range.cpp: In function‘intmain()’:
simd-range.cpp:13:17: error: ‘begin’ was not declared in this scope; did you mean ‘std::begin’?
13 |for (auto v : a) {
| ^
| std::begin
In file included from /usr/include/c++/13.2.1/string:53,
from /usr/include/c++/13.2.1/bitset:52,
from /usr/include/c++/13.2.1/experimental/bits/simd.h:33,
from /usr/include/c++/13.2.1/experimental/simd:74,
from simd-range.cpp:1:
/usr/include/c++/13.2.1/bits/range_access.h:114:37: note: ‘std::begin’ declared here
114 | template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;| ^~~~~
simd-range.cpp:13:17: error: ‘end’ was not declared in this scope; did you mean ‘std::end’?
13 |for (auto v : a) {
| ^
| std::end
/usr/include/c++/13.2.1/bits/range_access.h:116:37: note: ‘std::end’ declared here
116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;|
Expected Results
0
2
4
8
The text was updated successfully, but these errors were encountered:
Motivation
The library already provides indexed access. Providing a range interface/iterator access would allow the type to be used with all STL functions. Event though it would degrade to doing it element-wise, it would still vastly increase the ergonomics when some specific utility is not directly available for the
simd
type. It could also pave the way for specializing some STL functions, likestd::min_element
, instead of providinghmin
, addressing #18Let me know if you think this is a direction worth taking and I can write a PR
Testcase
Actual Results
Expected Results
The text was updated successfully, but these errors were encountered: