Opened 7 years ago
Last modified 7 years ago
#11650 new Bugs
boost range size() fails concept on subarray of a const multi_array
| Reported by: | Owned by: | Ronald Garcia | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | multi_array |
| Version: | Boost 1.59.0 | Severity: | Problem |
| Keywords: | Cc: |
Description
Small test case:
#include <boost/range/size.hpp>
#include <boost/multi_array.hpp>
using namespace boost;
typedef multi_array<float, 2> myarray;
myarray a;
const myarray const_a;
void
test() {
boost::size( a[0] ); // Compiles fine
boost::size( const_a ); // Compiles fine
boost::size( const_a[0] ); // Fails single pass range concept
}
gives me the attached errors. I'm using gcc 4.8.4 on Ubuntu 14.04 with boost 1.59.0
Attachments (1)
Change History (3)
by , 7 years ago
| Attachment: | errors.txt added |
|---|
comment:1 by , 7 years ago
It appears that the multi_array const_sub_array is not a valid model of a RandomAccessRange Concept because the iterator type id not defined.
A change to multi_array could make it work, I see two possibilities:
- Implement const_sub_array::iterator to be equal to const_sub_array::const_iterator. This has been done in Boost.Range sub_range without issue for sometime. This is semantically very similar since it needs to preserve constant-ness from a template parameter.
- The multi_array could have a specialization of boost::range_iterator to avoid using the default Boost.Range iterator type deduction.
My recommendation would be 1.
comment:2 by , 7 years ago
| Component: | range → multi_array |
|---|---|
| Owner: | changed from to |
Note:
See TracTickets
for help on using tickets.

Compilation errors