Boost logo

Boost :

Subject: Re: [boost] [array] change proposal for the c_array() function
From: Bo Persson (bop_at_[hidden])
Date: 2009-03-15 10:45:48


herve martin wrote:
> Niels Dekker wrote:
>
>> herve martin wrote:
>>
>>> I would submit a simple change request in the boost::array
>>> library.
>>>
>> ...
>>
>>> I suggest to change:
>>> T* c_array() { return elems; }
>>>
>>> into
>>> T (&c_array())[N] { return *(T(*)[N]) elems; }
>>>
>>
>> Believe it or not, I was considering to submit the very same
>> feature request. But go ahead:
>> https://svn.boost.org/trac/boost/newticket (Please consider
>> requesting a const overload as well!)
>>
>
> maybe I'm wrong but I don't think that we need the const overload
> since a T(&)[N] is implicitly convertible into a const T(&)[N] so
> { const int (&toto)[10] = (new boost::array<int,10>)->c_array() }
> should work.
>

Woudn't you need a const overload of c_array, if the original array is
const? Or you only have a const reference to it?

Bo Persson


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk