Benchmark of D against other languages
weaselcat via Digitalmars-d
digitalmars-d at puremagic.com
Wed Apr 1 21:41:12 PDT 2015
On Thursday, 2 April 2015 at 04:32:26 UTC, Martin Nowak wrote:
> On Thursday, 2 April 2015 at 04:11:02 UTC, weaselcat wrote:
>> was it a conscious decision to make the AA [] operator not
>> work like map/etc in C++?
>
> What do you mean?
accessing a non-existing element in C++'s map/unordered_map
inserts the default instead of raising an exception
int main(int argc, char *argv[])
{
std::unordered_map<std::string, int> test;
std::cout << test["hello"] << std::endl;
return 0;
}
prints 0
void main()
{
int[string] test;
writeln(test["hello"]);
}
core.exception.RangeError at source/main.d(9): Range violation
More information about the Digitalmars-d
mailing list