Monday, 19 August 2013

'vector iterators incompatible'

'vector iterators incompatible'

This question has been asked a number of times on SO, but the answers do
not apply to my situation, AFAICT. The following piece of code is
triggering the error immediately upon hitting i != std::end(observers_);.
void VisualGeometry::SignalPopPointFlags(const Point_2r& p,
const uint32_t msec_delay) const {
for(auto i = std::begin(observers_); i != std::end(observers_); ++i)
(*i)->SlotPopPointFlags(p, msec_delay);
}
Looking into <vector>, the following triggers the error:
void _Compat(const _Myiter& _Right) const
{ // test for compatible iterator pair
if (this->_Getcont() == 0
|| this->_Getcont() != _Right._Getcont())
{ // report error
_DEBUG_ERROR("vector iterators incompatible");
_SCL_SECURE_INVALID_ARGUMENT;
}
}
Since I am not comparing iterators from different containers, it seems
like the first check for this->_Getcont() == 0 might be the problem, but
I'm not sure how to tell.
The same problem occurs if I swap out begin(vec)/end(vec) for
vec.begin()/vec.end().
I'm a little lost as to how this can happen. Any advice on how to move
forward with debugging this?
The VisualGeometry class is designed to forward signals that it receives
onward to whichever objects are watching it. Here are relevant code
snippets:
class VisualGeometry : public IGeometryObserver, public IObservableGeometry {
public:
void SlotPushSegmentFlags(const Segment_2r& s, const uint32_t flags,
const uint32_t msec_delay = 0) override;
void SlotPopSegmentFlags(const Segment_2r& s,
const uint32_t msec_delay = 0) override;
void SignalPushSegmentFlags(const Segment_2r& s, const uint32_t flags,
const uint32_t msec_delay = 0) const
override;
void SignalPopSegmentFlags(const Segment_2r& s,
const uint32_t msec_delay = 0) const override;
/* snip */
private:
std::vector<IGeometryObserver*> observers_;
};
void VisualGeometry::SlotPushSegmentFlags(const Segment_2r& s,
const uint32_t flags,
const uint32_t msec_delay) {
SignalPushSegmentFlags(s, flags, msec_delay);
}
void VisualGeometry::SlotPopPointFlags(const Point_2r& p,
const uint32_t msec_delay) {
SignalPopPointFlags(p, msec_delay);
}
/* etc... */

No comments:

Post a Comment