Boost logo

Boost :

Subject: Re: [boost] [array] assignement operator
From: Joseph Gauterin (joseph.gauterin_at_[hidden])
Date: 2009-05-15 07:51:33


I think such an assignment operator is counter-intuitive and its use
will lead to hard to read code. I'd expect two objects to be
equivalent after one is assigned to the other. I certainly wouldn't
expect an array on the LHS to still contain some of its original
elements after a smaller RHS array is assigned to it.

Regards,
Joe.

On Fri, May 15, 2009 at 12:28 PM, vicente.botet
<vicente.botet_at_[hidden]> wrote:
> Boost.Array defines an assignement operator with the following prototype
>
>
> template<typename T, std::size_t N>
> class array {
> public:
>    /...
>    template<typename U>
>    array& operator=(const array<U, N>& rhs);
>    // Effects:std::copy(rhs.begin(),rhs.end(), begin())
> };
>
> I was wondering if this can be extended to manage with arrays of different sizes, having as effect the copying of the minimum of N and M elements from the source to the target.
>
> template<typename T, std::size_t N>
> class array {
> public:
>    /...
>    template<typename U, std::size_t M>
>    array& operator=(const array<U, M>& rhs);
>    // Effects:std::copy(rhs.begin(),rhs.begin()+min(N,M), begin())
> };
>
> Is there anything wrong with this interface?
>
> Best,
> _____________________
> Vicente Juan Botet Escribá
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


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