Opened 14 years ago

Last modified 14 years ago

#2129 new Feature Requests

iterator problem in ublas::basic_range (boost/numeric/ublas/storage.hpp)

Reported by: brian.tyler@… Owned by: Gunter
Milestone: To Be Determined Component: uBLAS
Version: Boost 1.35.0 Severity: Optimization
Keywords: Cc:

Description

Decrementing (--) a forward iterator through a basic_range containing negative values throws an error (bad_index). This seems inconsistent because it is possible to increment (++) through such a range without throwing error.

lines 937 - 941 of boost/numeric/ublas/storage.hpp read

const_iterator &operator -- () {
  BOOST_UBLAS_CHECK (it_ > 0, bad_index ());
  -- it_;
  return *this;
}

Removing "BOOST_UBLAS_CHECK (it_ > 0, bad_index ());" solves the problem. Similarly for the += and -= operators.

The documentation makes no mention of the range needing to consist only of positive values and this seems a rather arbitrary restriction.

Change History (1)

comment:1 by Gunter, 14 years ago

Milestone: Boost 1.36.0To Be Determined
Severity: ProblemOptimization
Type: BugsFeature Requests

The type of indices is by default "unsigned long". Thus we have to assure that we do not decrement a 0. Support of signed types for indices requires some work - I'll change this task to a feature request.

Additionally, we should add checks to the increment functions.

Note: See TracTickets for help on using tickets.