boost::multi_array_ref vs. boost::multi_array&

260 views Asked by At

Is there a reason to prefere the usage of boost::multi_array_ref over boost::multi_array&? Why is the adapter class boost::multi_array_ref provided by boost at all?

1

There are 1 answers

3
SergeyA On BEST ANSWER

Those would be two quite different things. boost::multi_array& is a reference which can be bound to already existing multi array, and you can use it for indirection to a 'true' multi array container.

On the other hand, boost::multi_array_ref is an adaptor - it allows one to use it with any other block of continuous data as if it was a multi array (while in fact it is not). (I personally think this is not a great name, as it implies a reference to the container)

See https://www.boost.org/doc/libs/1_73_0/libs/multi_array/doc/reference.html for more details.