Repository navigation
json_to_parameters as a function object (1.1.1) - #27
Merged
Merged
Conversation
…ent lookup; 1.1.1 numsim-materials declares its own json_to_parameters(json, schema, params) and calls it unqualified with numsim-core argument types. With the core function visible (any translation unit including both headers), argument-dependent lookup found both and the call no longer resolved to the materials version. A function object is never found by argument-dependent lookup.
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.
Problem
numsim-materials (all released versions) declares its own
json_to_parameters(json, schema, params)and calls it unqualified with numsim-core argument types (json_material_factory.h). In a translation unit that includes both numsim-materials andnumsim-core/json/json_parameter_converter.h(v1.1.0), argument-dependent lookup also finds the core function and the call breaks: it is ambiguous with nlohmann's ABI namespace, or the core overload wins. numsim-fft-homogenization hits this as soon as the application includes both.Fix
json_to_parametersis now aninline constexprfunction object with the same two call forms. Argument-dependent lookup never finds objects, so the other library's call resolves to its own function again. Qualified calls (numsim::core::json_to_parameters(...)) are unchanged, including designated-initialiser options.Version 1.1.1 for the tag.
Tests
Regression test
json_to_parameters.is_not_found_by_argument_dependent_lookup: a namespace with its own function taking core types calls it unqualified. Before the fix it fails to compile, after the fix it passes. GCC 13 Debug 164/164, GCC 14 Release 166/166. numsim-fft-homogenization built against this branch: 257/257.