Skip to content

fix: support zero-member types in NLOHMANN_DEFINE_TYPE_* macros#5195

Closed
ShahabAhmed01 wants to merge 1 commit into
nlohmann:developfrom
ShahabAhmed01:fix/macro-zero-members
Closed

fix: support zero-member types in NLOHMANN_DEFINE_TYPE_* macros#5195
ShahabAhmed01 wants to merge 1 commit into
nlohmann:developfrom
ShahabAhmed01:fix/macro-zero-members

Conversation

@ShahabAhmed01
Copy link
Copy Markdown

Summary

NLOHMANN_DEFINE_TYPE_* with no member fields produced invalid to_json / from_json bodies (e.g. nlohmann_json_j[] = nlohmann_json_t.).

This PR adds NLOHMANN_JSON_PASTE0 and NLOHMANN_JSON_DOUBLE_PASTE0 so empty __VA_ARGS__ expand to no-ops, matching the expected empty function bodies for zero members.

Fixes #4041.

Test plan

  • Added unit tests for intrusive and non-intrusive zero-member types in unit-udt_macro.cpp.

@github-actions
Copy link
Copy Markdown

🔴 Amalgamation check failed! 🔴

The source code has not been amalgamated. @ShahabAhmed01
Please read and follow the Contribution Guidelines.

@ShahabAhmed01 ShahabAhmed01 deleted the fix/macro-zero-members branch May 28, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NLOHMANN_DEFINE_TYPE_* fails with zero members

1 participant