Boost logo

Boost Users :

Subject: Re: [Boost-users] Error (runtime) assigning multi_array to multi_array with smaller dimensions
From: Oei, YC (oei.yungchin_at_[hidden])
Date: 2009-05-21 17:22:48


> //at class constructor
> boost::multi_array<char, 2> array2d = new boost::multi_array<char,
> 2>(boost::extents[x][y]);

> //at class method
> boost::multi_array<char, 1> array1d = array2d[0];

I tried out those two lines (minus the "new") here (see below), and
they compile without complaints in g++ 4.1.2.

Yung-Chin

-- contents of test file --

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

int main() {
    size_t x = 5;
    size_t y = 7;

    boost::multi_array<char, 2> array2d =
        boost::multi_array<char, 2>(boost::extents[x][y]);
    std::cout << array2d.num_dimensions() << std::endl;
    std::cout << array2d[0].num_dimensions() << std::endl;

    boost::multi_array<char, 1> array1d = array2d[0];
    std::cout << array1d.num_dimensions() << std::endl;
    return 0;
} //main


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