|
Boost Users : |
From: Ronald Garcia (garcia_at_[hidden])
Date: 2005-02-02 13:11:01
Hi Donald,
On Feb 1, 2005, at 4:50 PM, Donald Johnson wrote:
> I cant get boost::multi_array to wrk with STL algorithms. In particular
>
> boost::multi_array<int,2> test_array( boost::extents[10][10] );
> std::fill(test_array.begin(),test_array.end(),1);
>
> gives me the following compile errors.
>
...
> Do the provided iterators not work for stl algorithms?
>
>
Yes they do, but not in the manner that you think they do :). In the
code above, you are creating a 2 dimensional array. Calling begin() on
your array results in an iterator over the /one-dimensional arrays/
contained therein. Your code is trying to assign scalar values to
one-dimensional arrays, hence the type error. You can get the effect
that you are going for as follows.
std::
fill(test_array.data(),test_array.data()+test_array.num_elements(),1);
Hope this helps!
ron
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net