
Hi, This is already the case. Implicit conversions suffer of inequality after assignement, array<int, 2> a; array<double, 2> b; b[0]=0.5; b[1]=1.5; a=b; assert(a!=b); and this is not the single case; other classes suffer from the same symptom as std::pair. Do you find this counter-intuitive? Vicente ----- Original Message ----- From: "Joseph Gauterin" <joseph.gauterin@googlemail.com> To: <boost@lists.boost.org> Sent: Friday, May 15, 2009 1:51 PM Subject: Re: [boost] [array] assignement operator 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@wanadoo.fr> 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
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost