Jon Stewart on 8 Jul 2003 17:36:01 -0000 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [ALACPP] chapter 8 |
> I honestly am surprised when people make a mistake with operator[]. Most > of the time you look at the function prototype and realize there just > isn't a way to evaluate whether something is actually in the map or not. > However, I've been burned on this one enough to frequently dream about > putting something in my headers like, "using cbsmith::idiot_proof_map > map;" Yes, exactly. When applied correctly, it's useful and convenient. But the pain, oh, the pain, of debugging incorrect usage. Also, sometimes folks (you know who you are) get a bit clever and write something like this: myMap[key]; instead of: myMap.insert(std::make_pair(key, myMap::value_type()); which will put a default constructed value type into the map, associated with key. Such usage is obviously intentional, but demonstrates a sophomoric sense of humor. Jon -- Jon Stewart stew1@xxxxxxxxxxx _______________________________________________ alacpp mailing list alacpp@xxxxxxxxxxx http://lists.ellipsis.cx/mailman/listinfo/alacpp