Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost MultiArray Copy Constructor

I have got a problem understanding the copy constructor implementation of boost::multi_:array.

When I try the following

std::vector<double> a;
std::vector<double> b;
a.resize(12);
b.resize(10);
a=b;

everything works out fine,

but when I try

boost::multi_array<double,1> a;
boost::multi_array<double,1> b;
a.resize(boost::extents[12]);
b.resize(boost::extents[10]);
a=b;

I get a crash.

I expected the same behaviour, but I also could not find anything useful in the documentation.

Does anyone have an idea ?

Regards

awallrab

like image 719
awallrab Avatar asked Feb 03 '26 14:02

awallrab


1 Answers

It looks like boost::multi_array works just like std::valarray regarding assignment, that is the size of the 2 arrays must match.

According to the documentation:

Each of the array types multi_array, multi_array_ref, subarray, and array_view can be assigned from any of the others, so long as their shapes match.

like image 141
Randall Flagg Avatar answered Feb 06 '26 08:02

Randall Flagg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!