Compare commits

...
Author SHA1 Message Date
Niels Lohmann 6a17a07f0e Merge develop
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-28 07:11:40 +01:00
Niels Lohmann da83aa92c8 Reconcile -Weffc++ and readability-redundant-member-init in unit-bson.cpp (#5953) 2026-10-28 07:11:04 +01:00
Niels Lohmann 402af742c0 Fix the VS2015 build of unit-json_view_edit_values.cpp
MSVC 2015 treats two function templates that differ only in a decltype
return type as a redefinition (C2995), which breaks all three Visual
Studio 2015 jobs on AppVeyor. Overload on the view's mode in the
parameter type instead; template argument deduction ignores the
read-only-to-editable conversion, so each view still selects the
overload of its own mode.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-27 18:01:12 +01:00
2 changed files with 10 additions and 4 deletions

No files matched your search

+2
View File
@@ -1311,6 +1311,8 @@ TEST_CASE("BSON declared document size bounds the content")
// records the events that a SAX parser receives // records the events that a SAX parser receives
struct recorder : nlohmann::json_sax<json> struct recorder : nlohmann::json_sax<json>
{ {
// GCC's -Weffc++ wants the member initialized in the member initialization list
// NOLINTNEXTLINE(readability-redundant-member-init)
std::string events {}; std::string events {};
bool null() override bool null() override
+8 -4
View File
@@ -54,14 +54,18 @@ int accepts_any(nlohmann::basic_json_view<BasicJsonType, Mode> /*unused*/)
return Mode == nlohmann::view_mode::editable ? 3 : 4; return Mode == nlohmann::view_mode::editable ? 3 : 4;
} }
template<typename View> // overloads that differ only in the mode; deduction ignores the conversion from
auto overload(View v) -> decltype(accepts_editable(v)) // read-only to editable views, so each view picks the overload of its own mode
// (two templates that differ only in a decltype return type are a redefinition
// for MSVC 2015)
template<typename BasicJsonType>
int overload(nlohmann::basic_json_view<BasicJsonType, nlohmann::view_mode::editable> v)
{ {
return accepts_editable(v); return accepts_editable(v);
} }
template<typename View> template<typename BasicJsonType>
auto overload(View v) -> decltype(accepts_read_only(v)) int overload(nlohmann::basic_json_view<BasicJsonType, nlohmann::view_mode::read_only> v)
{ {
return accepts_read_only(v); return accepts_read_only(v);
} }