|
Re: Support for Indexing and Iteration Safety: msg#00349python.c++
"Mike Rovner" <mike@xxxxxxxxxxx> writes: > "David Abrahams" <dave@xxxxxxxxxxxxxxxxxxxx> wrote in message > news:u4r3dzibn.fsf@xxxxxxxxxxxxxxxxxxxxxxx >> Mike, please take this discussion to the C++-sig... > It is there. I did courtesy CC: when posted to -sig because original mail > felt into my e-mail inbox. ;) > >> > static void del(T& x, int n) { >> > if( n<0 ) n+=x.size(); >> > if( n<x.size() && n>=0 ) x.erase(&x[n]); >> > else IndexError(); } ^^^^^ >> > }; ^^^^^ >> Doesn't work (not an iterator). > Sorry. I'm spoiled by MSVC. Hope x.erase( Container<T>::iterator(&x[n]) ) > will do? > (with proper Container type) No, it won't. Not even with VC7. Something wrong with x.erase(x.begin() + n)? >> I have something a little less simplistic in mind. Why shouldn't >> everyone benefit? ;-) > > It will be very nice thing to have. > >> > My 0.02. Hope I made my point clear. >> >> Not really. The clearest message I can discern is "there's really not >> much of a problem". Is that really what you're saying? > > Not really. In my case I made it so with very simplistic approach > AND reducing my usage pattern. I recall my surprise it isn't in > place and sure agree with your answer "loud NO" to any unpredictable > behavior. So I understand why it's better not to have then have > unreliable. I tried to argue in support of having something shall > be reliable out of the box. I thought you were arguing for "return by value" as a default. If we accept the argument for "return by value" we are left unable to modify array elements: foo[x].bar = 1 If we accept simplistic return-by-reference we get a lack of safety. > For that goal it may be not the fastest and not the simplest. Agreed. |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Support for Indexing and Iteration Safety: 00349, Mike Rovner |
|---|---|
| Next by Date: | Re: Support for Indexing and Iteration Safety: 00349, David Abrahams |
| Previous by Thread: | Re: Support for Indexing and Iteration Safetyi: 00349, Mike Rovner |
| Next by Thread: | OpenSceneGraph bindings now hosted at sourceforge.: 00349, gideon may |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |