-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Add apply*() functions (visitor pattern) #3450
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
Draft
falbrechtskirchinger
wants to merge
11
commits into
nlohmann:develop
Choose a base branch
from
falbrechtskirchinger:apply
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add apply*() functions (visitor pattern) #3450
falbrechtskirchinger
wants to merge
11
commits into
nlohmann:develop
from
falbrechtskirchinger:apply
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94bae9b
to
fd9c467
Compare
9 tasks
50d9360
to
780a294
Compare
Fixes nlohmann#3130. Related discussion: nlohmann#3408
Document how CMake chooses which C++ standard version to use when building tests.
13e4102
to
973d979
Compare
Add 3 variants of apply*() functions that invoke a given callable with the supplied arguments and the stored JSON value. * void apply(Fn, Args...): ... * void apply_cb(ResultCallback, Fn, Args...): ... * R apply_r(Fn, Args...): ...
973d979
to
ad0373f
Compare
Clang <4 fails to compile std::forward_as_tuple() calls involving basic_json values. As a workaround, the values are wrapped using std::reference_wrapper.
595e4ae
to
2df1efd
Compare
Lambdas with certain noexcept specifiers are deemed non-invocable at compile-time, failing at runtime.
The invoke implemenation does not compile on GCC 8.1.0.
apply_invoke overload resolution fails for unknown reason.
2df1efd
to
04b4d79
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This has been factored out of #3446 but builds upon that PR and needs to be rebased.
Originally, I was looking for a workaround to be able to use
std::ranges::sort()
withbasic_json
.std::ranges::sort(j)
fails to compile becausebasic_json
doesn't (and can't) satisfy thestd:random_access_iterator
concept. This PR is the product of this search and adds 3 variants of visitor-styleapply*(Fn, Args...)
functions tobasic_json
which invoke a given callable (Fn
) with the stored JSON value and any additional arguments (Args...
).(Describe functions, etc.)
To Do: