Disambiguate GenericValue's [0] and ["string"]

This commit is contained in:
Zhihao Yuan
2014-10-23 11:44:16 -04:00
committed by Zhihao Yuan
parent 0d90bcc709
commit 7303d92990
4 changed files with 52 additions and 54 deletions

View File

@@ -72,12 +72,8 @@ int main(int, char*[]) {
for (SizeType i = 0; i < a.Size(); i++) // rapidjson uses SizeType instead of size_t.
printf("a[%d] = %d\n", i, a[i].GetInt());
// Note:
//int x = a[0].GetInt(); // Error: operator[ is ambiguous, as 0 also mean a null pointer of const char* type.
int y = a[SizeType(0)].GetInt(); // Cast to SizeType will work.
int z = a[0u].GetInt(); // This works too.
int y = a[0].GetInt();
(void)y;
(void)z;
// Iterating array with iterators
printf("a = ");