Boost logo

Boost :

From: Dave Gomboc (dave_at_[hidden])
Date: 2002-10-18 03:05:54


I am in the process of substituting boost::multi_array in for a homebrew
solution. One of my test cases unexpectedly failed with an assertion
error at line 369 of multi_array_ref.hpp, because there are no elements in
the array.

While it is perfectly possible for dynamically-sized containers (which
multi_array is not, granted) to have no elements within them, it doesn't
often occur that one would have such a statically-sized container. I
cracked open my copy of Austern '99 (GPSTL) to see if it is a condition of
"containerness" that a zero size must be supported. Section 5.2.4 gives
the example of the "trivial container". Section 9.1.1 states that "for
any Container a, [ a.begin(), a.end() ) is a valid range". But I can't
find text explicitly stating that a container where a.begin() == a.end()
must be supported. (FYI: I don't have a copy of the C++ standard.)

Does the multi_array code actually require that there not be zero elements
for the code to work properly, or is the assert is simply there because
"you probably don't want to be doing this"? In my case, I _do_ want to be
doing this -- I don't want to have special-case code when no storage is
actually needed, I'd rather have begin() == end() for the appropriate
dimensions so that loops involving such degenerate cases do no
computation.

Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk