Opened 8 years ago
Last modified 8 years ago
#10769 new Bugs
iterator_adaptor does not properly inherit "pointer" typedef from the base iterator
Reported by: | Owned by: | jeffrey.hellrung | |
---|---|---|---|
Milestone: | To Be Determined | Component: | iterator |
Version: | Boost 1.57.0 | Severity: | Problem |
Keywords: | Cc: |
Description
I'm trying to define a Derived_Iterator
class using a Base_Iterator
class and the glue class iterator_adaptor< Derived_Class, Base_Class, ...>
(as base of Derived_Iterator
). In my use case, neither pointers nor references are plain:
Base_Iterator::pointer != Base_Iterator::value_type* Base_Iterator::reference != Base_Iterator::value_type&
I found 2 possibly related problems, which I think are bugs:
- The typedef
iterator_adaptor<>::pointer
is incorrect. Specifically, it produces a plain pointer, when I expect it to produceBase_Iterator::pointer
.
- There is something wrong with
iterator_adaptor<>::operator->()
. I would expectDerived_Iterator
to behave exactly likeBase_Iterator
. So, if I don't explicitly defineDerived_Iterator::operator->()
, I would expect the version inherited fromiterator_adaptor<>
to do something similar to:Base_Iterator operator->() const { return this->base(); }
But this doesn't happen. If I put in this definition explicitly in Derived_Iterator
, then the code works.
Attachments (1)
Change History (3)
by , 8 years ago
Attachment: | iterator-example.cpp added |
---|
comment:1 by , 8 years ago
In the example, I'm using the bounded_pointer
and bounded_reference
classes that are part of the boost::intrusive
test suite, available in the github repo.
I compile with gcc-4.9.1
or clang-3.5
:
[g++|clang++] -std=c++11 -Wall -Wextra -pedantic -I${BOOST_INCLUDE_1_57} iterator-example.cpp -o iterator-example
comment:2 by , 8 years ago
I also posted a message about this on the boost-users mailing list, but Trac doesn't allow me to put the link here. (It thinks it's spam, then asks me solve a captcha without displaying one...)
example file