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: John Reid <johnbaronreid@…> 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)

errors.txt (7.8 KB ) - added by John Reid <johnbaronreid@…> 7 years ago.
Compilation errors

Download all attachments as: .zip

Change History (3)

by John Reid <johnbaronreid@…>, 7 years ago

Attachment: errors.txt added

Compilation errors

comment:1 by Neil Groves, 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:

  1. 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.
  2. 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 Neil Groves, 7 years ago

Component: rangemulti_array
Owner: changed from Neil Groves to Ronald Garcia
Note: See TracTickets for help on using tickets.