Hi! I'll take up on this one since I'm somewhat aware of the issues... I hope I'm not way off line. (If I am, please educate me! ;) ) Frank Hess wrote:
Does anyone know what the preferred method of accessing the underlying C array of a boost::array is? In boost 1.32 there is a data() member which returns a const pointer, and a c_array() member which returns a pointer. Also, the elems member itself is public.
I think the "preferred" method is to use the data() member function because that's what will be part of std::tr1::array, in the upcoming Technical Report that extends the C++ Standard. As you pointed out, though, to access the non-const pointer there is only the c_array() member in the current version of boost.
But at http://www.josuttis.com/cppcode/array.html, the author states that data() can be used for both const and non-const pointers, and indeed it is so in the version he posts on his website http://www.josuttis.com/cppcode/array.hpp.html (which doesn't provide the c_array() member but overloads data() instead).
This is a known "limitation" with the current version. IIUC, the plan is to update boost::array to reflect the changes introduced with TR1 for the next release. The c_array() member will probably be deprecated then. If you have that option, my personal suggestion is that you use the up-to-date version posted at the author's site while you wait for the boost release that'll set things right. Best regards, João Abecasis