Boost logo

Boost Users :

Subject: Re: [Boost-users] [multi_array] Why the precondition on assignment?
From: Joel Falcou (joel.falcou_at_[hidden])
Date: 2009-02-26 04:56:34


alfC a écrit :
>
> smart_assign(A)=B; // takes care of eventual resize. Used instead of
> A=B (which may fail), (both A and B are of type multi_array<double, 2>
> for example.)
>
> that was my way arround not being able to redefine operator=; but I am
> not sure if it is a good idea yet and whether it is a real improvement
> over just something like
> 'smart_assign(A, B);';

Tossing my few cents as I dealt with such shenanigans a lot of time.
In my own multi-array like class, I faced this dilemma. What I did was using
template boost::parameters to specify policy on allocation in the type
and had the user
make choice between throwing, static_asserting, silently reallocating,
preserving order etc

Why not using such policies ? I know it involves drastically changing
multi_array interface but maybe it's worth the hassle.
Just let the default parameters be the old multi_array semantic.


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