#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: |
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 (1)
Change History (5)
by , 10 years ago
| Attachment: | iterator-range-pointer-to-array.patch added |
|---|
comment:1 by , 10 years ago
comment:3 by , 9 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.

patch + test