|
Boost Users : |
From: gast128 (gast128_at_[hidden])
Date: 2005-08-04 02:51:58
me22 <me22.ca <at> gmail.com> writes:
>
> On 03/08/05, gast128 <gast128 <at> hotmail.com> wrote:
> > Dear all,
> >
> > I was wondering why boost::array did not offer compile time checked access
to
> > its contents, something like a.get<1>(), a similar interface like tuple.
> > Otherwise I see not much enhancement compared to an ordinary std::vector.
> >
> > Wkr,
> > me
> >
>
> boost::array is allocated on the stack like a normal array, while a
> std::vector needs to use an allocator, usually putting it on the heap.
>
> Also, the normal usage pattern for arrays ( dynamic or otherwise ) is
> looping through them, the accesses in which cannot be compile-time
> checked. Note, however, that operator[] does assert that the index is
> valid--which quickly caught me a bug a little while back.
>
> - Scott McMurray
Yes I can see for myself that there are differences between boost::array and
the vector. My point is only that one can add a compile time safe accessor to
this array. This does not invalidate the need for a run time accessor like
operator[]. Also this would create a big advantage over the vector. This heap
and stack allocation stough could just be seen as implementation details.
Wkr,
me
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net