-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Allow custom base class as node customization point #3110
Allow custom base class as node customization point #3110
Conversation
f3671da
to
8ed9dd7
Compare
Just saw i used the wrong base branch and fixed it. |
8ed9dd7
to
471b245
Compare
Not sure about the cppcheck error, but there are also issues with MSVC. |
Great! Windows seem to work now. The amalgamation check failed though. Please try again after calling |
For some strange reason The cppcheck test was skipped this time, so it did not fail. I guess it will fail again.
The ci uses cppcheck 2.7. This seems to be some version of the current main branch. If i build cppcheck main and use it, i get the same error. It looks like a false positive. I could suppress it using |
Unfortunately, this can happen. You fixed it the right way. Sorry for the inconvenience.
Yes, the CI uses the bleeding-edge version of cppcheck. If you can suppress the issue, then I guess this is the way. |
Not sure why it displayed a green tick earlier... |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
3311d11
to
e0a30ee
Compare
@nlohmann Please approve the workflow run. |
Strange... not sure why the previous run of cppcheck accepted the code without the suppress comment. I guess it is a sporadic error. Hence i added the comment again. |
5e700cc
to
1b983c8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Some notes for a follow-up PR:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments, but otherwise looks good to me.
Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com>
Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com>
Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com>
Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com>
Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com>
Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com>
🔴 Amalgamation check failed! 🔴The source code has not been amalgamated. |
Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Will merge once the CI is green. |
🔴 Amalgamation check failed! 🔴The source code has not been amalgamated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Thanks a lot!!! |
Thanks to you guys, too. I really like this library and know it is a lot of work to maintain libraries. |
@@ -1200,11 +1204,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec | |||
/// @brief move constructor | |||
/// @sa https://json.nlohmann.me/api/basic_json/basic_json/ | |||
basic_json(basic_json&& other) noexcept | |||
: m_type(std::move(other.m_type)), | |||
: json_base_class_t(std::move(other)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@barcode Sorry for being so late, but now I got a warning from Clang-Tidy about accessing other.m_value
after moving other
in the line before. Any idea how to fix this?
This PR adds an additional template parameter which allows to set a custom base class for
nlohmann::json
. This class serves as an extension point and allows to add functionality to json node. Examples for such functionality might be metadata or additional member functions (e.g. visitors) or other application specific code.By default the parameter is set to void and an empty base class is used. In this case the library behaves as it already did.
Pull request checklist
Read the Contribution Guidelines for detailed information.
include/nlohmann
directory, runmake amalgamate
to create the single-header filesingle_include/nlohmann/json.hpp
. The whole process is described here.