Hi,

Matthieu Fertré a écrit :
> Ok, no problem. I have initially replaced it thinking it was a vector. 
> On a vector, if I remember correctly, .at(i) is equivalent to [i] but 
> .at(i) checks that the vector is long enough and i is not out of range, 
> [i] don't do that.

Meaning that if the code was at fault, a clean exception/error message 
would be thrown instead of just a segfault?

Anyway, you're right. The description of at() over cppreference.com for 
std::vector does say that. Thought, they don't mention the at() operator 
for std::map. The sgi doc doesn't mention any at() method for any of 
those objects, so I don't know what is supposed to be stl-standard.

> But here, it's a map and not a vector, so I'm not sure what could be the 
> difference between .at() and [].

I didn't see anything bad with it, as I thought it was just another way. 
Seems I was wrong. Well, you gotta learn something new each day.

Regards,
Kurosu

_______________________________________________
Wormux-dev mailing list
Wormux-dev@gna.org
https://mail.gna.org/listinfo/wormux-dev

Répondre à