Opened 19 years ago

Closed 19 years ago

Last modified 19 years ago

#215 closed Bugs (Invalid)

compiler error using multi_array w/ <algorithm>

Reported by: dtrauma Owned by: nobody
Milestone: Component: None
Version: None Severity:
Keywords: Cc:

Description

[boost 1.30.2, gcc3.3.2]

Hi there,

when using multi_array I get compile time errors if I
try to use them with <algorithm> like this:

#include <algorithm>
#include <boost/multi_array.hpp>

int main () {
	//straight from the docs         
	typedef boost::multi_array<double, 3> array_type;
	typedef array_type::extent_range range;

	array_type::extent_gen extents;
 
	array_type A(extents[2][3][4]);
	
	//each of those will fail with
	//enough errors to fill a novel

	//read access
	std::find(A.begin(), A.end(), 42.);
	//write access
	std::fill(A.begin(), A.end(), 42.);
}

Is it my fault? I tried it with boost/array.hpp and it
worked, so I assumed it should work with multi-array, too.
So there are three possibilities:
	1.) I am a fool
	2.) multi_array fools me
	3.) gcc fools me
or any combination of those; could someone de-fool the
situation? :-)

compiler output attached

Change History (2)

comment:1 by david_abrahams, 19 years ago

Status: assignedclosed
Logged In: YES 
user_id=52572

The iterators of a three-dimensional multi_array iterate over 
two-dimensional subarrays, not over floats.  Does that help?

comment:2 by dtrauma, 19 years ago

Logged In: YES 
user_id=590875

So it was 1.), indeed. After re-reading the docs, I think I
got misled by the Reference Manual, Invariants: "Iteration
through the range [a.begin(),a.end()) will traverse across
every value_type of a."

After reading the definition of value_type, it all gets clear.

Too bad, I'll have to get me another container, then.

Thanks for the quick help, sorry for the entropy in your inbox.
Note: See TracTickets for help on using tickets.