Re: Array vs std::vector + free operators
Posted by
DU VIGNAUD DE VILLEFORT FRANCOIS GASAPRD PHI on
Apr 19, 2007; 5:52pm
URL: http://quantlib.414.s1.nabble.com/Array-vs-std-vector-free-operators-tp9392p9393.html
>Apart from adding operations to std::vector, the above is not as
>efficient as Array:operator+. if you write
>std::vector<Real> w = u+w;
>the addition returns a Disposable, but the std::vector constructor
>doesn't know what to do with it, so it copies its contents instead of
>swapping. If you want full efficiency, you have to write:
>std::vector<Real> w;
>w.swap(u+v);
>which is more awkward. On the other hand, Array defines a constructor
>taking a Disposable, so there's no moving in
>Array w = u+v;
I badly missed this point, I will slap myself with bjarne's book ;-)
François
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev