boost::compute::valarray should support std::begin and std::end
- Dominant language
- C++
- Stars
- 1.7k
- Forks
- 340
- PR merge metrics
- No merged PRs in 30d
Description
I want to be able to copy a `compute::valarray` to a `std::valarray` like this:
```c++
std::valarray h(0.0f,1000);
compute::valarray d(1.0f,1000);
compute::copy(std::begin(d), std::end(d), std::begin(h));
```
This fails because `begin()` and `end()` are private (http://www.boost.org/doc/libs/1_62_0/libs/compute/doc/html/boost/compute/valarray.html).
In contrast, `begin()` and `end()` are supported for `std::valarray` since C++11 (http://en.cppreference.com/w/cpp/numeric/valarray).
I solved the issue locally with the following trivial change.
```c++
//private:
buffer_iterator begin() const
{
return buffer_iterator(m_buffer, 0);
}
buffer_iterator end() const
{
return buffer_iterator(m_buffer, size());
}
```
Is this an acceptable change? It would be nice if `boost::compute::valarray` behaved like C++11 `std::valarray`.
I can contribute the trivial change if that is sufficient. If a more complicated one is required, I'll do my best.
Contributor guide
Assessment
This issue has not been assessed yet.