You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[MSVC][std:c++latest] JSON failed with error C2678: binary '==': no operator found which takes a left-hand operand of type 'nlohmann::json_abi_v3_11_2::json'
#3868
Open
1 of 2 tasks
QuellaZhang opened this issue
Dec 7, 2022
· 4 comments
unit-constructor1.cpp
F:\gitP\nlohmann\json\tests\src\unit-constructor1.cpp(282,13): error C2088: '==': illegal for class
unit-iterators2.cpp
F:\gitP\nlohmann\json\tests\src\unit-iterators2.cpp(946,17): error C2678: binary '==': no operator found which takes a left-hand operand of type 'nlohmann::json_abi_v3_11_2::json' (or there is no acceptable conversion)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\thread(242,36): note: could be 'bool std::operator ==(std::thread::id,std::thread::id) noexcept' [found using argument-dependent lookup]
F:\gitP\nlohmann\json\include\nlohmann/json.hpp(3680,10): note: or 'bool nlohmann::json_abi_v3_11_2::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_11_2::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>::operator ==(const nlohmann::json_abi_v3_11_2::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_11_2::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void> &) noexcept const' [synthesized expression 'y == x']
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\thread(242,36): note: or 'bool std::operator ==(std::thread::id,std::thread::id) noexcept' [synthesized expression 'y == x']
F:\gitP\nlohmann\json\tests\thirdparty\doctest\doctest.h(1238,9): note: or 'unknown-type doctest::detail::Expression_lhs<std::ranges::reverse_view<std::ranges::ref_view<nlohmann::json_abi_v3_11_2::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_11_2::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>>> &>::operator ==(R &&)'
F:\gitP\nlohmann\json\tests\src\unit-iterators2.cpp(946,17): note: Failed to specialize function template 'unknown-type doctest::detail::Expression_lhs<std::ranges::reverse_view<std::ranges::ref_view<nlohmann::json_abi_v3_11_2::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_11_2::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>>> &>::operator ==(R &&)'
F:\gitP\nlohmann\json\tests\src\unit-iterators2.cpp(946,17): note: With the following template arguments:
F:\gitP\nlohmann\json\tests\src\unit-iterators2.cpp(946,17): note: 'R=nlohmann::json_abi_v3_11_2::json &'
F:\gitP\nlohmann\json\include\nlohmann/json.hpp(3697,10): note: or 'bool nlohmann::json_abi_v3_11_2::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::json_abi_v3_11_2::adl_serializer,std::vector<uint8_t,std::allocator<uint8_t>>,void>::operator ==(ScalarType) noexcept const' [synthesized expression 'y == x']
F:\gitP\nlohmann\json\tests\src\unit-iterators2.cpp(946,17): note: the associated constraints are not satisfied
F:\gitP\nlohmann\json\include\nlohmann/json.hpp(3696,14): note: the constraint was not satisfied
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\include\utility(367,27): note: or 'bool std::operator ==(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)'
F:\gitP\nlohmann\json\tests\src\unit-iterators2.cpp(946,17): note: 'bool std::operator ==(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)': could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from
F:\gitP\nlohmann\json\tests\src\unit-iterators2.cpp(946,17): error C2660: 'doctest::detail::decomp_assert': function does not take 4 arguments
F:\gitP\nlohmann\json\tests\thirdparty\doctest\doctest.h(1425,28): note: see declaration of 'doctest::detail::decomp_assert'
F:\gitP\nlohmann\json\tests\src\unit-iterators2.cpp(946,17): note: while trying to match the argument list '(doctest::assertType::Enum, const char [52], int, const char [23])'
Description
After the MSVC team implemented P2468R2 The Equality Operator You Are Looking For, we got compiler errors with /std:c++latest like below. The way this fails is that the != operator here: https://github.com/nlohmann/json/blob/develop/include/nlohmann/json.hpp#L3704 actually suppresses the rewritten operator candidates and stops the code from compiling because the rewritten candidates are discarded. Could you please look this issue? Thanks.
Note: this issue will be reproduced on next release version of VS(17.6 or later).
Reproduction steps
Expected vs. actual results
Expected Result:
The build was successful.
Actual Result:
build.log: JSON_amd64_build.log
Minimal code example
No response
Error messages
No response
Compiler and operating system
Internal unreleased MSVC
Library version
develop branch of 8f83153
Validation
develop
branch is used.The text was updated successfully, but these errors were encountered: