Is the following code legal?
Shachar Shemesh via Digitalmars-d
digitalmars-d at puremagic.com
Wed Nov 2 07:21:32 PDT 2016
int[int] hash;
..
foreach( key, ref value; hash ) {
if( value>12 )
hash.remove(key);
}
Some hash implementations support this, some don't. The D documentation
(https://dlang.org/spec/hash-map.html) leaves this not defined.
As reference, C++ does define this (in C++ it is allowed, at least since
C++14: http://en.cppreference.com/w/cpp/container/unordered_map/erase)
Shachar
More information about the Digitalmars-d
mailing list