On Fri, Aug 19, 2005 at 09:19:55AM +0100, Jonathan Wakely wrote:
> WU Yongwei wrote:
> 
> > Well, I see this in the gcc error message.  Can someone here kindly
> > point to me which part of the Standard specified this behaviour?  I
> > thought it should be in 5.3.4, but was not able to find the words
> > there.
> 
> It might be better if the error message said "non-default
> initialization" since default initialization is allowed (and required).
> 
> I assume you are trying something like this:
> 
>     int* i = new int[5](23);

While this is not gcc-help, maybe we could make a FAQ item for this.
For people who want to do something like this, I suggest

    std::vector<int> i(5, 23);

If the reason vector wasn't used in the first place was because some
API needs an array, then use

    std::vector<int> vector_i(5, 23);
    int* i = &*vector.begin();

The reason for the &* is to convert the vector iterator into a
pointer to the first element.

Reply via email to