Boost logo

Boost Users :

Subject: [Boost-users] extents
From: Alle Meije Wink (a.m.wink_at_[hidden])
Date: 2010-10-22 10:54:17


Dear all,

I am trying to load data from a file, where they are (obviously)
stored as a 1D contiguous block, to a N-dimensional array.

For the type of files I use N could be 1 through 8. I have code to for
a 1..8-dimensional container (as a class template), but how to load in
the data from the file?

The multi_array_ref way to do it looked ideal, eg for a 3D float-image
something like
   im = image_ref< float, 2 >( image->data, boost::extents[512][512] )
might work.

But to code the different dimensionalities in a neat way would mean to
store the extents in a variable (or something), like

boost_extents_type e;
switch ndim { // ndim=dim[0]
   1:
   int dim1=dim[1];
   e=boost::extents[dim1];
   break;
   2:
   int dim1=dim[1],dim2=dim[2];
   e=boost::extents[dim1][dim2];
//etc
}

Is something like this possible with extents?

Many thanks,
Alle Meije


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