Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #414 - comparing to 0 literal #415

Merged
merged 2 commits into from
Feb 16, 2017
Merged

Conversation

stanmihai4
Copy link

Add a function overload for comparing to int, so that the 0 literal is not converted to nullptr.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling e38be0a on stanmihai4:develop into 9755cc7 on nlohmann:develop.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling ecb161a on stanmihai4:develop into 9755cc7 on nlohmann:develop.

@nlohmann
Copy link
Owner

Please fix this PR - when I remove the functions friend bool operator==(const_reference v, std::nullptr_t) noexcept and friend bool operator==(std::nullptr_t, const_reference v) noexcept, I cannot compile the tests any more:

[CXXLD] test-cbor
src/unit-cbor.cpp:31:9: warning: keyword is hidden by macro definition
      [-Wkeyword-macro]
#define private public
        ^
src/unit-cbor.cpp:747:29: error: use of overloaded operator '==' is ambiguous
      (with operand types 'json' (aka 'basic_json<>') and 'nullptr_t')
                    CHECK(j == nullptr);
                          ~ ^  ~~~~~~~
thirdparty/catch/catch.hpp:10503:44: note: expanded from macro 'CHECK'
#define CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDispositio...
                                           ^~~~
thirdparty/catch/catch.hpp:2083:41: note: expanded from macro
      'INTERNAL_CATCH_TEST'
    } while( Catch::isTrue( false && !!(expr) ) ) // expr here is never ...
                                        ^~~~
../src/json.hpp:5580:17: note: candidate function
    friend bool operator==(const_reference lhs, const_reference rhs) noexcept
                ^
src/unit-cbor.cpp:747:29: note: built-in candidate operator==(nullptr_t,
      nullptr_t)
                    CHECK(j == nullptr);
                            ^

Overload comparison operators for all types that could be converted
to nullptr.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.002%) to 99.962% when pulling 6bf93b3 on stanmihai4:develop into 82fb613 on nlohmann:develop.

@stanmihai4
Copy link
Author

Do you have an update on what will happen to this PR ?

@nlohmann
Copy link
Owner

@stanmihai4 Sorry, i did not find the time for this PR. I shall definitely have a look before the next release!

nlohmann added a commit that referenced this pull request Feb 16, 2017
@nlohmann nlohmann merged commit 6bf93b3 into nlohmann:develop Feb 16, 2017
@nlohmann
Copy link
Owner

Thanks a lot @stanmihai4! I merged this branch with 057b1e6.

@nlohmann nlohmann self-assigned this Feb 16, 2017
@nlohmann nlohmann added this to the Release 2.1.1 milestone Feb 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants