rapidjson
rapidjson copied to clipboard
Visual Studio 2022 (using /std:c++20) new warning
Hello, I've a Value compare in my code (around line 340)
bool fnc(const Value&js1,const Value&js2)
{
return (!(js1!=js2));
}
I updated rapidjson code to master, I've a Visual Studio 2022 (using /std:c++20) new warning
1>N:\nouvo_repo\exterieur\rapidjson\include\rapidjson\document.h(1036,76): warning C5232: in C++20 this comparison calls 'bool rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::operator ==<rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>(const rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>> &) const' recursively
1>(compiling source file 'include/ama_vu_base.cpp')
1>N:\nouvo_repo\exterieur\rapidjson\include\rapidjson\document.h(1036,76):
1>the template instantiation context (the oldest one first) is
1> N:\nouvo_repo\demobug.cpp.cpp(340,23):
1> see reference to function template instantiation 'bool rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::operator ==<rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>(const rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>> &) const' being compiled
1> N:\nouvo_repo\demobug.cpp.cpp(340,9):
1> see the first reference to 'rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::operator ==' in 'nsAmaLib::compare_json_objet_avec_exception'
1>N:\nouvo_repo\exterieur\rapidjson\include\rapidjson\document.h(1045,32): warning C5232: in C++20 this comparison calls 'bool rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::operator ==<rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>(const rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>> &) const' recursively
it seem modify document.h line 1036 and 1045 like this sole the problem: I remplaced two '!=' between Value by '==' with a logic not (!)
if (rhsMemberItr == rhs.MemberEnd() || lhsMemberItr->value != rhsMemberItr->value)
can be replaced by:
if (rhsMemberItr == rhs.MemberEnd() || (!(lhsMemberItr->value == rhsMemberItr->value)))
if ((*this)[i] != rhs[i])
can be replaced by:
if (!((*this)[i] == rhs[i]))
for (ConstMemberIterator lhsMemberItr = MemberBegin(); lhsMemberItr != MemberEnd(); ++lhsMemberItr) {
typename RhsType::ConstMemberIterator rhsMemberItr = rhs.FindMember(lhsMemberItr->name);
if (rhsMemberItr == rhs.MemberEnd() || (!(lhsMemberItr->value == rhsMemberItr->value)))
return false;
}
return true;
case kArrayType:
if (data_.a.size != rhs.data_.a.size)
return false;
for (SizeType i = 0; i < data_.a.size; i++)
if (!((*this)[i] == rhs[i]))
return false;
sorry, I made a clone of #2150