open-source-parsers / jsoncpp

A C++ library for interacting with JSON.
Other
8.06k stars 2.63k forks source link

May it better that using ArrayIndex= size_t rather than ArrayIndex=unsigned int? #1496

Open biepenghaomie opened 1 year ago

biepenghaomie commented 1 year ago

When I use size_t in 32bit version,it can work for get index of object.But when i transform my code compile to 64bit,it will error with match more than one opeartor. Finally,I find jsoncpp using ArrayIndex=unsigned int.It equal size_t which is usigned int in 32bit too.But size_t is usigned long long in 64bit. So,may it better that using ArrayIndex= size_t rather than ArrayIndex=unsigned int?Let cpp compiler tool chain decide to use unsigned int or usigned long long.

appgurueu commented 7 months ago

I agree with this issue; unsigned int seems like an inappropriate type to use for array indices, since it is only required to be 16 bits wide, which need not be enough for indexing JSON arrays. std::size_t is a more fitting type since the address width serves as a natural upper bound on the width of array indices.