Skip to content

json_to_parameters as a function object (1.1.1) - #27

Merged
petlenz merged 1 commit into
mainfrom
fix/json-to-parameters-adl
Oct 4, 2026
Merged

petlenz merged 1 commit into
mainfrom
fix/json-to-parameters-adl

Conversation

@petlenz

@petlenz petlenz commented Oct 4, 2026

Copy link
Copy Markdown
Member

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 and numsim-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_parameters is now an inline constexpr function 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.

…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.
@petlenz
petlenz merged commit fedbc89 into main Oct 4, 2026
6 checks passed
@petlenz
petlenz deleted the fix/json-to-parameters-adl branch October 4, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant