Boost logo

Boost :

From: Joe Gottman (jgottman_at_[hidden])
Date: 2005-05-31 19:40:22

"AlisdairM" <alisdair.meredith_at_[hidden]> wrote in message
> Aggregate initialization is an important part of the array concept,
> allowing it to act largely as a plug-in replacement for language
> arrays, with the bonus it can be passed by value as well as by
> reference. The main drawback here is that we cannot deduce the size of
> a boost::array, as you can with a language array.

   I know this is looking ahead quite a bit, but the next version of C++ is
going to have a new meaning for the "auto" keyword. The code
    auto x = foo();
will declare x as a variable whose type is deduced from the return type of
foo() (See
for details).

It should be possible to use this to create a function that creates an array
of the correct size:
    template <class T>
    array<T, 1> make_array(const T &t1);

    template <class T>
    array<T, 2> make_array(const T &t1, const T &t2);

    template <class T>
    array<T, 3> make_array(const T &t1, const T &t2, const T &t3);


  Then we would be able to write code like
   auto my_array = make_array(1,2, 3); // The type of my_array is array<int,

Joe Gottman

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