Open nlohmann opened 11 months ago
this appear to be libcxx specific, as I couldn't reproduce it until I installed it and set CXX="clang++ -stdlib=libc++"
defining JSON_HAS_THREE_WAY_COMPARISON
to 1 fixes the issue. I see // # define __cpp_lib_three_way_comparison 201907L
in the libcxx sources (at least the revision I have fetched locally). this trips the check in json.hpp.
Thanks for the hint.
With -DJSON_HAS_THREE_WAY_COMPARISON=1
and Apple Clang, I get:
❯ make create_output
standard
/Library/Developer/CommandLineTools/usr/bin/make examples/operator_spaceship__const_reference.c++20 \
CPPFLAGS="-I ../single_include -DJSON_USE_GLOBAL_UDLS=0 -DJSON_HAS_THREE_WAY_COMPARISON=1" \
CXXFLAGS="-std=c++20 -Wno-deprecated-declarations"
c++ -std=c++20 -Wno-deprecated-declarations -I ../single_include -DJSON_USE_GLOBAL_UDLS=0 -DJSON_HAS_THREE_WAY_COMPARISON=1 examples/operator_spaceship__const_reference.c++20.cpp -o examples/operator_spaceship__const_reference.c++20
In file included from examples/operator_spaceship__const_reference.c++20.cpp:3:
../single_include/nlohmann/json.hpp:22948:33: error: invalid operands to binary expression ('array_t' (aka 'vector<basic_json<std::map, std::vector, string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>, void>, allocator<basic_json<std::map, std::vector, string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>, void>>>') and 'array_t')
JSON_IMPLEMENT_OPERATOR(<=>, // *NOPAD*
~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
../single_include/nlohmann/json.hpp:22815:52: note: expanded from macro 'JSON_IMPLEMENT_OPERATOR'
return (*lhs.m_data.m_value.array) op (*rhs.m_data.m_value.array); \
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
examples/operator_spaceship__const_reference.c++20.cpp:36:79: note: in instantiation of member function 'nlohmann::basic_json<>::operator<=>' requested here
std::cout << array_1 << " <=> " << array_2 << " := " << to_string(array_1 <=> array_2) << '\n'; // *NOPAD*
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__threading_support:682:17: note: candidate function not viable: no known conversion from 'array_t' (aka 'vector<basic_json<std::map, std::vector, string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>, void>, allocator<basic_json<std::map, std::vector, string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>, void>>>') to '__thread_id' for 1st argument
strong_ordering operator<=>(__thread_id __x, __thread_id __y) noexcept {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__variant/monostate.h:32:49: note: candidate function not viable: no known conversion from 'array_t' (aka 'vector<basic_json<std::map, std::vector, string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>, void>, allocator<basic_json<std::map, std::vector, string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>, void>>>') to 'monostate' for 1st argument
_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(monostate, monostate) noexcept {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/system_error:481:1: note: candidate function not viable: no known conversion from 'array_t' (aka 'vector<basic_json<std::map, std::vector, string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>, void>, allocator<basic_json<std::map, std::vector, string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>, void>>>') to 'const error_code' for 1st argument
operator<=>(const error_code& __x, const error_code& __y) noexcept
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/system_error:489:1: note: candidate function not viable: no known conversion from 'array_t' (aka 'vector<basic_json<std::map, std::vector, string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>, void>, allocator<basic_json<std::map, std::vector, string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>, void>>>') to 'const error_condition' for 1st argument
operator<=>(const error_condition& __x, const error_condition& __y) noexcept
^
../single_include/nlohmann/json.hpp:2894:34: note: candidate function not viable: no known conversion from 'array_t' (aka 'vector<basic_json<std::map, std::vector, string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>, void>, allocator<basic_json<std::map, std::vector, string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>, void>>>') to 'const value_t' for 1st argument
inline std::partial_ordering operator<=>(const value_t lhs, const value_t rhs) noexcept // *NOPAD*
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__utility/pair.h:444:1: note: candidate template ignored: could not match 'pair' against 'vector'
operator<=>(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__iterator/reverse_iterator.h:288:1: note: candidate template ignored: could not match 'reverse_iterator' against 'vector'
operator<=>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__iterator/reverse_iterator.h:288:1: note: candidate template ignored: could not match 'reverse_iterator' against 'vector'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:566:1: note: candidate template ignored: could not match 'unique_ptr' against 'vector'
operator<=>(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:566:1: note: candidate template ignored: could not match 'unique_ptr' against 'vector'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:658:1: note: candidate template ignored: could not match 'unique_ptr' against 'vector'
operator<=>(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:658:1: note: candidate template ignored: could not match 'unique_ptr' against 'vector'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/shared_ptr.h:1374:1: note: candidate template ignored: could not match 'shared_ptr' against 'vector'
operator<=>(shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) noexcept
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/shared_ptr.h:1374:1: note: candidate template ignored: could not match 'shared_ptr' against 'vector'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/shared_ptr.h:1483:1: note: candidate template ignored: could not match 'shared_ptr' against 'vector'
operator<=>(shared_ptr<_Tp> const& __x, nullptr_t) noexcept
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/shared_ptr.h:1483:1: note: candidate template ignored: could not match 'shared_ptr' against 'vector'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/tuple:1572:1: note: candidate template ignored: could not match 'tuple' against 'vector'
operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/tuple:1572:1: note: candidate template ignored: could not match 'tuple' against 'vector'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/string_view:784:1: note: candidate template ignored: could not match 'basic_string_view' against 'vector'
operator<=>(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) noexcept {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/string_view:797:38: note: candidate template ignored: could not match 'basic_string_view' against 'vector'
_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/string_view:797:38: note: candidate template ignored: could not match 'basic_string_view' against 'vector'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/variant:1659:1: note: candidate template ignored: could not match 'variant' against 'vector'
operator<=>(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__iterator/move_iterator.h:282:6: note: candidate template ignored: could not match 'move_iterator' against 'vector'
auto operator<=>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__iterator/move_iterator.h:282:6: note: candidate template ignored: could not match 'move_iterator' against 'vector'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/string:4077:38: note: candidate template ignored: could not match 'basic_string' against 'vector'
_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/string:4085:1: note: candidate template ignored: could not match 'basic_string' against 'vector'
operator<=>(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/string:4085:1: note: candidate template ignored: could not match 'basic_string' against 'vector'
In file included from examples/operator_spaceship__const_reference.c++20.cpp:3:
../single_include/nlohmann/json.hpp:22948:33: error: invalid operands to binary expression ('object_t' (aka 'map<std::string, nlohmann::basic_json<std::map, std::vector, std::string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char>>, void>, less<>, allocator<std::pair<const string, basic_json<std::map, std::vector, string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>, void>>>>') and 'object_t')
JSON_IMPLEMENT_OPERATOR(<=>, // *NOPAD*
~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
../single_include/nlohmann/json.hpp:22818:53: note: expanded from macro 'JSON_IMPLEMENT_OPERATOR'
return (*lhs.m_data.m_value.object) op (*rhs.m_data.m_value.object); \
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__threading_support:682:17: note: candidate function not viable: no known conversion from 'object_t' (aka 'map<std::string, nlohmann::basic_json<std::map, std::vector, std::string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char>>, void>, less<>, allocator<std::pair<const string, basic_json<std::map, std::vector, string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>, void>>>>') to '__thread_id' for 1st argument
strong_ordering operator<=>(__thread_id __x, __thread_id __y) noexcept {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__variant/monostate.h:32:49: note: candidate function not viable: no known conversion from 'object_t' (aka 'map<std::string, nlohmann::basic_json<std::map, std::vector, std::string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char>>, void>, less<>, allocator<std::pair<const string, basic_json<std::map, std::vector, string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>, void>>>>') to 'monostate' for 1st argument
_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(monostate, monostate) noexcept {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/system_error:481:1: note: candidate function not viable: no known conversion from 'object_t' (aka 'map<std::string, nlohmann::basic_json<std::map, std::vector, std::string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char>>, void>, less<>, allocator<std::pair<const string, basic_json<std::map, std::vector, string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>, void>>>>') to 'const error_code' for 1st argument
operator<=>(const error_code& __x, const error_code& __y) noexcept
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/system_error:489:1: note: candidate function not viable: no known conversion from 'object_t' (aka 'map<std::string, nlohmann::basic_json<std::map, std::vector, std::string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char>>, void>, less<>, allocator<std::pair<const string, basic_json<std::map, std::vector, string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>, void>>>>') to 'const error_condition' for 1st argument
operator<=>(const error_condition& __x, const error_condition& __y) noexcept
^
../single_include/nlohmann/json.hpp:2894:34: note: candidate function not viable: no known conversion from 'object_t' (aka 'map<std::string, nlohmann::basic_json<std::map, std::vector, std::string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char>>, void>, less<>, allocator<std::pair<const string, basic_json<std::map, std::vector, string, bool, long long, unsigned long long, double, std::allocator, nlohmann::adl_serializer, vector<unsigned char, allocator<unsigned char>>, void>>>>') to 'const value_t' for 1st argument
inline std::partial_ordering operator<=>(const value_t lhs, const value_t rhs) noexcept // *NOPAD*
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__utility/pair.h:444:1: note: candidate template ignored: could not match 'pair' against 'map'
operator<=>(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__iterator/reverse_iterator.h:288:1: note: candidate template ignored: could not match 'reverse_iterator' against 'map'
operator<=>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__iterator/reverse_iterator.h:288:1: note: candidate template ignored: could not match 'reverse_iterator' against 'map'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:566:1: note: candidate template ignored: could not match 'unique_ptr' against 'map'
operator<=>(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:566:1: note: candidate template ignored: could not match 'unique_ptr' against 'map'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:658:1: note: candidate template ignored: could not match 'unique_ptr' against 'map'
operator<=>(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:658:1: note: candidate template ignored: could not match 'unique_ptr' against 'map'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/shared_ptr.h:1374:1: note: candidate template ignored: could not match 'shared_ptr' against 'map'
operator<=>(shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) noexcept
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/shared_ptr.h:1374:1: note: candidate template ignored: could not match 'shared_ptr' against 'map'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/shared_ptr.h:1483:1: note: candidate template ignored: could not match 'shared_ptr' against 'map'
operator<=>(shared_ptr<_Tp> const& __x, nullptr_t) noexcept
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/shared_ptr.h:1483:1: note: candidate template ignored: could not match 'shared_ptr' against 'map'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/tuple:1572:1: note: candidate template ignored: could not match 'tuple' against 'map'
operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/tuple:1572:1: note: candidate template ignored: could not match 'tuple' against 'map'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/string_view:784:1: note: candidate template ignored: could not match 'basic_string_view' against 'map'
operator<=>(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) noexcept {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/string_view:797:38: note: candidate template ignored: could not match 'basic_string_view' against 'map'
_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/string_view:797:38: note: candidate template ignored: could not match 'basic_string_view' against 'map'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/variant:1659:1: note: candidate template ignored: could not match 'variant' against 'map'
operator<=>(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__iterator/move_iterator.h:282:6: note: candidate template ignored: could not match 'move_iterator' against 'map'
auto operator<=>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__iterator/move_iterator.h:282:6: note: candidate template ignored: could not match 'move_iterator' against 'map'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/string:4077:38: note: candidate template ignored: could not match 'basic_string' against 'map'
_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/string:4085:1: note: candidate template ignored: could not match 'basic_string' against 'map'
operator<=>(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/string:4085:1: note: candidate template ignored: could not match 'basic_string' against 'map'
In file included from examples/operator_spaceship__const_reference.c++20.cpp:3:
../single_include/nlohmann/json.hpp:22948:33: error: invalid operands to binary expression ('binary_t' (aka 'byte_container_with_subtype<std::vector<unsigned char, std::allocator<unsigned char>>>') and 'binary_t')
JSON_IMPLEMENT_OPERATOR(<=>, // *NOPAD*
~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
../single_include/nlohmann/json.hpp:22839:53: note: expanded from macro 'JSON_IMPLEMENT_OPERATOR'
return (*lhs.m_data.m_value.binary) op (*rhs.m_data.m_value.binary); \
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__threading_support:682:17: note: candidate function not viable: no known conversion from 'binary_t' (aka 'byte_container_with_subtype<std::vector<unsigned char, std::allocator<unsigned char>>>') to '__thread_id' for 1st argument
strong_ordering operator<=>(__thread_id __x, __thread_id __y) noexcept {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__variant/monostate.h:32:49: note: candidate function not viable: no known conversion from 'binary_t' (aka 'byte_container_with_subtype<std::vector<unsigned char, std::allocator<unsigned char>>>') to 'monostate' for 1st argument
_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(monostate, monostate) noexcept {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/system_error:481:1: note: candidate function not viable: no known conversion from 'binary_t' (aka 'byte_container_with_subtype<std::vector<unsigned char, std::allocator<unsigned char>>>') to 'const error_code' for 1st argument
operator<=>(const error_code& __x, const error_code& __y) noexcept
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/system_error:489:1: note: candidate function not viable: no known conversion from 'binary_t' (aka 'byte_container_with_subtype<std::vector<unsigned char, std::allocator<unsigned char>>>') to 'const error_condition' for 1st argument
operator<=>(const error_condition& __x, const error_condition& __y) noexcept
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__utility/pair.h:444:1: note: candidate template ignored: could not match 'pair' against 'byte_container_with_subtype'
operator<=>(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__iterator/reverse_iterator.h:288:1: note: candidate template ignored: could not match 'reverse_iterator' against 'byte_container_with_subtype'
operator<=>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__iterator/reverse_iterator.h:288:1: note: candidate template ignored: could not match 'reverse_iterator' against 'byte_container_with_subtype'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:566:1: note: candidate template ignored: could not match 'unique_ptr' against 'byte_container_with_subtype'
operator<=>(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:566:1: note: candidate template ignored: could not match 'unique_ptr' against 'byte_container_with_subtype'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:658:1: note: candidate template ignored: could not match 'unique_ptr' against 'byte_container_with_subtype'
operator<=>(const unique_ptr<_T1, _D1>& __x, nullptr_t) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:658:1: note: candidate template ignored: could not match 'unique_ptr' against 'byte_container_with_subtype'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/shared_ptr.h:1374:1: note: candidate template ignored: could not match 'shared_ptr' against 'byte_container_with_subtype'
operator<=>(shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) noexcept
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/shared_ptr.h:1374:1: note: candidate template ignored: could not match 'shared_ptr' against 'byte_container_with_subtype'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/shared_ptr.h:1483:1: note: candidate template ignored: could not match 'shared_ptr' against 'byte_container_with_subtype'
operator<=>(shared_ptr<_Tp> const& __x, nullptr_t) noexcept
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/shared_ptr.h:1483:1: note: candidate template ignored: could not match 'shared_ptr' against 'byte_container_with_subtype'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/tuple:1572:1: note: candidate template ignored: could not match 'tuple' against 'byte_container_with_subtype'
operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/tuple:1572:1: note: candidate template ignored: could not match 'tuple' against 'byte_container_with_subtype'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/string_view:784:1: note: candidate template ignored: could not match 'basic_string_view' against 'byte_container_with_subtype'
operator<=>(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) noexcept {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/string_view:797:38: note: candidate template ignored: could not match 'basic_string_view' against 'byte_container_with_subtype'
_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/string_view:797:38: note: candidate template ignored: could not match 'basic_string_view' against 'byte_container_with_subtype'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/variant:1659:1: note: candidate template ignored: could not match 'variant' against 'byte_container_with_subtype'
operator<=>(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__iterator/move_iterator.h:282:6: note: candidate template ignored: could not match 'move_iterator' against 'byte_container_with_subtype'
auto operator<=>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__iterator/move_iterator.h:282:6: note: candidate template ignored: could not match 'move_iterator' against 'byte_container_with_subtype'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/string:4077:38: note: candidate template ignored: could not match 'basic_string' against 'byte_container_with_subtype'
_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/string:4085:1: note: candidate template ignored: could not match 'basic_string' against 'byte_container_with_subtype'
operator<=>(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/string:4085:1: note: candidate template ignored: could not match 'basic_string' against 'byte_container_with_subtype'
3 errors generated.
make[1]: *** [examples/operator_spaceship__const_reference.c++20] Error 1
make: *** [examples/operator_spaceship__const_reference.c++20.output] Error 2
And with GCC 13:
❯ CXX=g++-13 make create_output
standard
/Library/Developer/CommandLineTools/usr/bin/make examples/operator_spaceship__const_reference.c++20 \
CPPFLAGS="-I ../single_include -DJSON_USE_GLOBAL_UDLS=0 -DJSON_HAS_THREE_WAY_COMPARISON=1" \
CXXFLAGS="-std=c++20 -Wno-deprecated-declarations"
g++-13 -std=c++20 -Wno-deprecated-declarations -I ../single_include -DJSON_USE_GLOBAL_UDLS=0 -DJSON_HAS_THREE_WAY_COMPARISON=1 examples/operator_spaceship__const_reference.c++20.cpp -o examples/operator_spaceship__const_reference.c++20
ld: warning: ignoring duplicate libraries: '-lgcc'
0 0x101017648 __assert_rtn + 72
1 0x100f4bfac ld::AtomPlacement::findAtom(unsigned char, unsigned long long, ld::AtomPlacement::AtomLoc const*&, long long&) const + 1204
2 0x100f61924 ld::InputFiles::SliceParser::parseObjectFile(mach_o::Header const*) const + 15164
3 0x100f6ee30 ld::InputFiles::parseAllFiles(void (ld::AtomFile const*) block_pointer)::$_7::operator()(unsigned long, ld::FileInfo const&) const + 420
4 0x183e8f950 _dispatch_client_callout2 + 20
5 0x183ea2ba0 _dispatch_apply_invoke + 176
6 0x183e8f910 _dispatch_client_callout + 20
7 0x183ea13cc _dispatch_root_queue_drain + 864
8 0x183ea1a04 _dispatch_worker_thread2 + 156
9 0x1840390d8 _pthread_wqthread + 228
ld: Assertion failed: (resultIndex < sectData.atoms.size()), function findAtom, file Relocations.cpp, line 1336.
collect2: error: ld returned 1 exit status
make[1]: *** [examples/operator_spaceship__const_reference.c++20] Error 1
make: *** [examples/operator_spaceship__const_reference.c++20.output] Error 2
seems that GCC discovered a bug in apple's ld there - 'fun'.
fwiw, I was testing against upstream llvm 17, so I'm not sure I can say what's going on on apple clang (but I suspect the <=> impl is incomplete, which'd be implied by the lack of the FTM, even in llvm 17)
sorry, I don't have an apple machine I could dig in further on :-/
I can post the output that GCC produced on my machine, if that helps, though
I really need help here. Beside yet another issue in the CI, this issue blocks the next release.
iirc, this was due to apple clang using outdated libcxx, and libcxx (even newer versions) not having all of three_way_compare implemented. it worked on my system because we have recent enough libcxx in gentoo, so just telling json.h to ignore the FTM not existing worked well enough.
i'd either use gcc or newer clang and the workaround to get the release out
Unfortunately, @ArsenArsen is right. Currently those check are :
#if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L
and
&& defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L
The first one is true on macOS clang 15, as the compiler is supporting the operator. But the second check is false, as the library does not support the operator yet, which is requires for basic_json class (as it forward <=> to std::vector
So the solutions are :
Now if I understand right, the output is just used for diff testing, we could #if JSON_HAS_THREE_WAY_COMPARISON
around the whole file, and fake the test
An example of faking for documentation
#if JSON_HAS_THREE_WAY_COMPARISON
// output values and comparisons
std::cout << array_1 << " <=> " << array_2 << " := " << to_string(array_1 <=> array_2) << '\n'; // *NOPAD*
std::cout << object_1 << " <=> " << object_2 << " := " << to_string(object_1 <=> object_2) << '\n'; // *NOPAD*
std::cout << string << " <=> " << number << " := " << to_string(string <=> number) << '\n'; // *NOPAD*
std::cout << string << " <=> " << discarded << " := " << to_string(string <=> discarded) << '\n'; // *NOPAD*
#else
// fake values and comparisons when compiler is not supporting
std::cout << array_1 << " <=> " << array_2 << " := " << "less" << '\n'; // *NOPAD*
std::cout << object_1 << " <=> " << object_2 << " := " << "equivalent" << '\n'; // *NOPAD*
std::cout << string << " <=> " << number << " := " << "greater" << '\n'; // *NOPAD*
std::cout << string << " <=> " << discarded << " := " << "unordered" << '\n'; // *NOPAD*
#endif
writing definition explicitly for operator <=> is one of the solutions unless we want to wait for clang to include this definition for our consumption.
Description
I want to prepare the next release, but compiling the example file
docs/examples/operator_spaceship__const_reference.c++20.cpp
fails.Reproduction steps
Compile file
docs/examples/operator_spaceship__const_reference.c++20.cpp
.docs/examples/operator_spaceship__const_reference.c++20.output
make -Cdocs create_output
Expected vs. actual results
Expected: No error.
Actual: Compilation error.
Minimal code example
Error messages
Compiler and operating system
Apple clang version 15.0.0 (clang-1500.0.40.1)
Library version
develop
Validation
develop
branch is used.