Use the #3669 fixture's optional member in to_json

Issue3669Holder::d is never read, so clang's -Weverything -Werror build
(ci_test_clang) fails with -Wunused-private-field. Reference the member
in the hidden-friend to_json; this does not affect the instantiation
cycle the fixture reproduces.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann
2026-09-27 18:38:52 +02:00
parent 86ea63185e
commit 5d7d4a9ae6
+2 -1
View File
@@ -280,8 +280,9 @@ class Issue3669Holder
// GCC < 11 (C++11/14) rejects a free to_json(json&, const Issue3669Holder&) // GCC < 11 (C++11/14) rejects a free to_json(json&, const Issue3669Holder&)
// here, because ADL for Issue3669Dummy finds it and closes an instantiation // here, because ADL for Issue3669Dummy finds it and closes an instantiation
// cycle; a hidden friend is only visible to ADL for Issue3669Holder // cycle; a hidden friend is only visible to ADL for Issue3669Holder
friend void to_json(json& j, const Issue3669Holder& /*unused*/) friend void to_json(json& j, const Issue3669Holder& h)
{ {
static_cast<void>(h.d); // silence -Wunused-private-field
j = "holder"; j = "holder";
} }
}; };