Suggestion for multi_array query information

Hello, I have a short suggestion about the interface for multi_array. It is possible to query a multi_array<T,N> for information about the storage: // queries ... const size_type* shape() const; const index* strides() const; const index* index_bases() const; ... It appears multi_array uses a boost::array internally to store this information, and uses the data() method to return a pointer in the above methods. Wouldn't it be better to return a reference to the array directly: // queries ... const array<size_type, N>& shape() const; const array<index, N>& strides() const; const array<index, N>& index_bases() const; ... With this interface the information about the number of elements of shapes and strides is not lost during the query. -- Anders Edin, Sidec Technologies AB Fogdevreten 2A, 171 77 Stockholm, Sweden Phone: +46850884525, Fax: +46850884522

Greetings Anders, On Oct 11, 2004, at 12:18 PM, Anders Edin wrote:
It appears multi_array uses a boost::array internally to store this information, and uses the data() method to return a pointer in the above methods. Wouldn't it be better to return a reference to the array directly:
The multi_array class template matches the requirements of the MultiArray concept, which specifies that the member functions that you mention return pointers. Other types in the Boost.MultiArray library, such as views and subarrays also implement MultiArray, but subarrays for example do not store the same information in boost::arrays. Thus the various types share a common interface so that they can be used generically. Hope this helps, ron
participants (2)
-
Anders Edin
-
Ronald Garcia