Boost logo

Boost :

Subject: Re: [boost] Proposal: boost::make_array()
From: Marc Glisse (marc.glisse_at_[hidden])
Date: 2013-01-13 17:41:47


On Sun, 13 Jan 2013, Yves Bailly wrote:

> On 01/13/2013 09:42 PM, Marshall Clow wrote:
>> On Jan 12, 2013, at 5:43 PM, Yves Bailly <yves.bailly_at_[hidden]> wrote:
>>> On 01/12/2013 05:45 PM, Kyle Lutz wrote:
>>>> I'd like to propose a new function for the Boost Array library named
>>>> make_array(). The function constructs a fixed size array given N
>>>> arguments
>>>> and is similar to the make_pair() and make_tuple() functions.
>>>> [...]
>>>> The code is available on github at https://github.com/kylelutz/make_array
>>>
>>> Sorry if it's a genuine question... But in the case of C++11, wouldn't it
>>> be
>>> simpler to use an expansion instead of the "push_array" function?
>>> Something
>>> like this:
>>
>> In C++11, you can just use an initializer list:
>>
>> boost::array<int, 5> {{ 0, 1, 2, 3, 4 }};
>
> I'm aware of this, I was just suggesting a simpler writing for the
> proposed "make_array" function.
>
> However I'm wondering about a use case where "make_array" would be
> useful, given the aggregate syntax.

People often complain that they can write:

int a[]={1,2,3};

but for std::array they have to specify the size manually. make_array
helps with that, for instance. Note that in some cases, we would want to
be able to specify the type without specifying the length, it would be
really cool if make_array<type>(a, b, c) also worked (using the same name
makes it a bit complicated though).

-- 
Marc Glisse

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