Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#8338 closed Bugs (fixed)

Iterator range does not work with pointer to array as iterator

Reported by: Nathan Ridge Owned by: Neil Groves
Milestone: To Be Determined Component: range
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:


The following code:

#include <boost/range/iterator_range.hpp>

template <typename T>
boost::iterator_range<const T*> one_element_range(const T& t)
    return boost::iterator_range<const T*>(&t, &t + 1);

int main()

fails to compile with the following error:

In file included from test.cpp:1:
In file included from boost/range/iterator_range.hpp:13:
boost/range/iterator_range_core.hpp:349:12: error: function cannot return array type 'abstract_value_type' (aka 'char [4]')
           abstract_value_type operator()( difference_type at ) const
test2.cpp:11:5: note: in instantiation of template class 'boost::iterator_range<char const (*)[4]>' requested here

I think this use case (pointer to an array as an iterator) should be supported.

Attachments (1)

iterator-range-pointer-to-array.patch (1.6 KB) - added by Nathan Ridge 5 years ago.
patch + test

Download all attachments as: .zip

Change History (5)

Changed 5 years ago by Nathan Ridge

patch + test

comment:1 Changed 5 years ago by Nathan Ridge

(In [83596]) [range] allow iterator_range to be instantiated with a pointer to an array as the iterator type (refs #8338)

comment:2 Changed 5 years ago by Nathan Ridge

Fixed in trunk.

comment:3 Changed 4 years ago by Nathan Ridge

Resolution: fixed
Status: newclosed

(In [84823]) [range] Merge Boost.Range bug fixes to release branch (fixes #6944; fixes #7407; fixes #7408; fixes #7731; fixes #7827; fixes #8338; fixes #8453).

comment:4 Changed 4 years ago by Nathan Ridge

Fixed for 1.54.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Neil Groves.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.