Boost logo

Boost :

Subject: Re: [boost] Proposal: boost::make_array()
From: Kyle Lutz (kyle.r.lutz_at_[hidden])
Date: 2013-01-13 14:39:57

On Sun, Jan 13, 2013 at 11:23 AM, Thomas Heller <thom.heller_at_[hidden]>
> On Sunday, January 13, 2013 14:36:50 Mathias Gaunard wrote:
> > On 13/01/2013 10:38, Thomas Heller wrote:
> > > The C++11 code looks too complicated. Wouldn't
> > > be enough?

Indeed it is! I've updated the C++11 code to use the simpler initialization
method. Thanks!

> >
> > I don't think it is a good idea that make_array(1, 1., 1.f) makes an
> > array of int.
> > It seems quite arbitrary that the first argument would decide the type.
> Right. That is another problem. I just tried to simplify the
implementation of
> the original proposal.

As far as type-deduction, how would you guys feel about an implementation
using boost::common_type? Something along the lines of:

// make_array with deduced type
template<class... Args>
inline array<typename common_type<Args...>::type, sizeof...(Args)>
make_array(Args&&... args)
    typedef typename common_type<Args...>::type T;

        array<T, sizeof...(Args)> {{

So that make_array(1, 2.1f) would return array<float, 2> and make_array(1,
2.1f, 3.2) would return array<double, 3>.



Boost list run by bdawes at, gregod at, cpdaniel at, john at