Iterating through multi_array_ref like a C-array

S

Sean Connery

Hi,

I have the following type and variable:

typedef boost::multi_array_ref<T,2> array_2d_ref;
array_2d_ref cpr_table(pT,boost::extents [range(1,360)]
[range(1,2)]);

When I try to iterate through it using the shape() function as follows:

for(index i = 1; i <= cpr_table.shape()[0]; ++i)
{
for(index j = 1; j <= cpr_table.shape()[1]; ++j)
{
cout << cpr_table[j].val.num << " ";
}
cout << endl;
}

I get signed/vs unsigned warnings.

I don't want to turn these off, nor do I want to ignore them for any
translation unit. How can I iterate through this array using the 2-d
C-array semantics without iterators?

Also, if there is a better newsgroup, please let me know.

Thanks

Sean

PS: Catch me in my latest movie, james bond 008.
 
J

Jeff Flinn

Sean Connery said:
Hi,

I have the following type and variable:

typedef boost::multi_array_ref<T,2> array_2d_ref;
array_2d_ref cpr_table(pT,boost::extents [range(1,360)]
[range(1,2)]);

When I try to iterate through it using the shape() function as follows:

for(index i = 1; i <= cpr_table.shape()[0]; ++i)
{
for(index j = 1; j <= cpr_table.shape()[1]; ++j)
{
cout << cpr_table[j].val.num << " ";
}
cout << endl;
}

I get signed/vs unsigned warnings.

I don't want to turn these off, nor do I want to ignore them for any
translation unit. How can I iterate through this array using the 2-d
C-array semantics without iterators?

Also, if there is a better newsgroup, please let me know.


Join the boost users mailing list. See www.boost.org for details. Once
you've joined, you can use www.gmane.org to view the mailing list postings
with a newsreader, as if it were a normal newsgroup.

Jeff Flinn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,203
Messages
2,571,059
Members
47,668
Latest member
SamiraShac

Latest Threads

Top