Opened 11 years ago
Last modified 10 years ago
#5965 new Bugs
indirect_iterator conflicts with forward declaration
Reported by: | Owned by: | jeffrey.hellrung | |
---|---|---|---|
Milestone: | To Be Determined | Component: | iterator |
Version: | Boost 1.46.1 | Severity: | Problem |
Keywords: | Cc: | jeffrey.hellrung |
Description
indirect_iterator, or more precisely its base class indirect_base, checks whether it can dereference its argument twice. This ends in an error, if the target type is incomplete (from a forward declaration). The error occurs even if the dereferencing is not used in the affected code unit. (It is concept checking.)
/usr/include/boost/detail/is_incrementable.hpp:84: error: cannot increment a pointer to incomplete type ‘Derived’
indirect_iterator handles pointers. Pointers and forward declaration should complete each other well. So indirect_iterator should never try to dereference if it is not forced by using code. Concept checking does not work here satisfactorily.
I appended exemplary code which I compiled with GCC 4.4.3.
Best regards,
Simon
Attachments (3)
Change History (6)
by , 11 years ago
by , 11 years ago
Attachment: | Derived.hpp added |
---|
The sub-class. A list of pointers to this class is saved in the base class.
comment:1 by , 10 years ago
The immediate problem actually appears to lie in boost::pointee, so one can partially specialize boost::pointee for pointer types to avoid instantiating is_incrementable. However, after doing this, a new problem arises with instantiating boost::is_POD on the value_type of the indirect_iterator (which, in this case, is Derived) during determination of the return type of operator[]. So, a possible resolution for your specific example would be to disable operator[] when the traversal of the underlying iterator is not random access. I'll see what I can do to effect this.
comment:2 by , 10 years ago
Cc: | added |
---|
comment:3 by , 10 years ago
Owner: | changed from | to
---|
The base class with a forward declaration and a range for a certain sub-class.