STL like Vector,Pair, Map
Bill Baxter
dnewsgroup at billbaxter.com
Tue Nov 13 23:14:38 PST 2007
Sean Kelly wrote:
> David B. Held wrote:
>>
>> It will be very hard to provide STL containers until we get struct
>> d'tors and copy c'tors (contrary to how Janice trivializes the task ;).
Yes, defintely do watch out for that BLS.
>
> Why?
STL containers act like value types.
std::vector<int> a,b;
...// put some stuff in vector a
b = a; // now b has a copy of every element of a
a[4] = 9; //b[4] unchanged
In D currently to get that behavior have to do .dup:
int[] a,b;
b = a.dup;
So my STL-like interfaces have D-ish dup functions to make value copies.
But BLS, you should watch out for any such assignments of STL containers
in your code, and change them to a = b.dup type things.
--bb
More information about the Digitalmars-d
mailing list