Opened 4 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: nathanridge Owned by: neilgroves
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 nathanridge 4 years ago.
patch + test

Download all attachments as: .zip

Change History (5)

Changed 4 years ago by nathanridge

patch + test

comment:1 Changed 4 years ago by nathanridge

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

comment:2 Changed 4 years ago by nathanridge

Fixed in trunk.

comment:3 Changed 4 years ago by nathanridge

  • Resolution set to fixed
  • Status changed from new to closed

(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 nathanridge

Fixed for 1.54.

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain neilgroves.
The resolution will be deleted. Next status will be 'reopened'.

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

Note: See TracTickets for help on using tickets.