Boost logo

Boost Users :

From: Ronald Garcia (garcia_at_[hidden])
Date: 2005-11-12 10:33:15


Hi Joshua,

I'm not completely clear on what you are attempting to do below, so I
have turned what you wrote into a complete program. Does the following
capture your intent?

#include <list>
#include "boost/multi_array.hpp"

struct C {
   int m_foo;
};

int main() {
   boost::multi_array<std::list<C>, 3> listbin(boost::extents[3][3][3]);

   /// Walk through list at 0,0,0
   for(std::list<C>::iterator iter = listbin[0][0][0].begin();
       iter != listbin[0][0][0].end(); ++iter)
   {
       iter->m_foo += 42;
   }

}

The above compiles under GCC 3.3. Does it compile with your compiler?

Cheers,
ron

On Oct 26, 2005, at 1:46 PM, Joshua Schpok wrote:

> I want to make a 3D array of std::lists:
>
> boost::multi_array<std::list<CSomething>,3> listbin;
>
> Then I'd like to actually use those lists:
>
> /// Walk through list at x,y,z
> for(std::list<CSomething>::iterator iter = listbin[x][y][z].begin();
> reti != iter[x][y][z].end(); iter++)
> {
> iter->m_foo += 42;
> }
>
> But multi_array is giving me back *const* list iterators, producing the
> error:
>
> error: conversion from `std::_List_const_iterator<CSomething>' to
> non-scalar type `std::_List_iterator<CSomething>'
> requested
>
> Why is this so? I can trick the compiler by doing a cast like:
>
> std::list<CSomething>::iterator iter =
> ((std::list<CSomething>)listbin[x][y][z]).begin();
>
> but this seems to poop out at runtime. Is there a proper way to do
> this?
>
> Joshua Schpok
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


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