Add apply*() functions (visitor pattern)#3450
Draft
falbrechtskirchinger wants to merge 11 commits intonlohmann:developfrom
Draft
Add apply*() functions (visitor pattern)#3450falbrechtskirchinger wants to merge 11 commits intonlohmann:developfrom
falbrechtskirchinger wants to merge 11 commits intonlohmann:developfrom
Conversation
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
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
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_jsondoesn't (and can't) satisfy thestd:random_access_iteratorconcept. This PR is the product of this search and adds 3 variants of visitor-styleapply*(Fn, Args...)functions tobasic_jsonwhich invoke a given callable (Fn) with the stored JSON value and any additional arguments (Args...).(Describe functions, etc.)
To Do: