fix: nlohmann::adl_serializer for std::optional#9147
Merged
Ericson2314 merged 9 commits intoNixOS:masterfrom Nov 30, 2023
Merged
fix: nlohmann::adl_serializer for std::optional#9147Ericson2314 merged 9 commits intoNixOS:masterfrom
nlohmann::adl_serializer for std::optional#9147Ericson2314 merged 9 commits intoNixOS:masterfrom
Conversation
This allows templates such as `NLOHMANN_DEFINE_TYPE_*` templates and other generators with things like `std::vector<std::optional<T>>`.
Member
|
@aakropotkin Can you test that your way works for deserializing types that do not have a default constructor? It looks like it would, but nlohmann/json is very finicky about this (it has some bad old stuff for backwards compat that instead mutates a default-constructed value). |
Contributor
Author
Yeah I have a test case in my repo I can migrate over here. |
Member
|
Great, feel free to undraft once you have the tests. |
Contributor
Author
|
Aight - we ready |
tomberek
approved these changes
Nov 29, 2023
nlohmann::adl_serializer for std::optional
tebowy
pushed a commit
to tebowy/nix
that referenced
this pull request
Jul 11, 2024
This allows templates such as `NLOHMANN_DEFINE_TYPE_*` templates and other generators with things like `std::vector<std::optional<T>>`. Co-authored-by: John Ericson <John.Ericson@Obsidian.Systems> (cherry picked from commit 02bd821) Change-Id: I8b0ebcf2af4226610dadd565962f2d2327415a03
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.
Motivation
This allows templates such as
NLOHMANN_DEFINE_TYPE_*templates and other generators with things likestd::vector<std::optional<T>>.Context
This template definition conflicts with my own definition used in a
nixplugin.I can use y'alls copy but since I nest
std::optionalinside of other STL containers.Priorities
Add 👍 to pull requests you find important.