Modify

Ticket #8338 (closed Bugs: fixed)

Opened 13 months ago

Last modified 10 months ago

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:

Description

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()
{
    one_element_range("foo");
}

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
    one_element_range("foo");
    ^

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

Attachments

iterator-range-pointer-to-array.patch Download (1.6 KB) - added by nathanridge 13 months ago.
patch + test

Change History

Changed 13 months ago by nathanridge

patch + test

comment:1 Changed 13 months 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 13 months ago by nathanridge

Fixed in trunk.

comment:3 Changed 10 months ago by nathanridge

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

(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 10 months ago by nathanridge

Fixed for 1.54.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


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

 
Note: See TracTickets for help on using tickets.