Open oath-jia opened 11 years ago
You can do some Type Casting
and check. However, there is something wrong with the comment. And this also can be the wrong of the user, the interface is size_t
, why you pass a negative value?
Just because of the comment in value.h
// Return true if successful, or false if the index is negative or
// the value is a null pointer
bool Set(size_t index, Value* in_value)
For example, in
bool Set(size_t index, Value* in_value)
,index
is asize_t
number. So though we executelist.Set(-1, in_value)
, the computer think that-1
is not -1 but 4294967295. If we judgeif (index >= 0)
, it's always right. How should I deal with this.