From 5204ebb0d0672bfbb27594754eadc32e317f5d26 Mon Sep 17 00:00:00 2001 From: Raphael Grimm Date: Mon, 1 Nov 2021 15:59:56 +0100 Subject: [PATCH] Add documentation --- .../nlohmann/detail/json_custom_base_class.hpp | 17 +++++++++++++++++ tests/src/unit-custom-base-class.cpp | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/include/nlohmann/detail/json_custom_base_class.hpp b/include/nlohmann/detail/json_custom_base_class.hpp index 0f1fbfd1f..5e6d66ae9 100644 --- a/include/nlohmann/detail/json_custom_base_class.hpp +++ b/include/nlohmann/detail/json_custom_base_class.hpp @@ -7,6 +7,23 @@ namespace nlohmann namespace detail { +/*! +@brief Default base class of the @ref basic_json class. + +So that the correct implementation of the copy / move ctors / assign operators +of @ref basic_json does not require complex case distinctions +(no base class / custom base class), @ref basic_json always a base class. +By default this class is used, since empty and thus has no effect on the +behaviour of @ref basic_json. + + +So that the correct implementation of the copy / move ctors / assign operators +of @ref basic_json does not require complex case distinctions +(no base class / custom base class used as customization point), +@ref basic_json always has a base class. +By default, this class is used because it is empty and thus has no effect +on the behavior of @ref basic_json. +*/ struct json_default_base {}; template diff --git a/tests/src/unit-custom-base-class.cpp b/tests/src/unit-custom-base-class.cpp index 8259cacd9..d42938979 100644 --- a/tests/src/unit-custom-base-class.cpp +++ b/tests/src/unit-custom-base-class.cpp @@ -35,6 +35,8 @@ SOFTWARE. #include +// Test extending nlohmann::json by using a custom base class. +// Add some metadata to each node ant test the behaviour of copy / move template class json_metadata { @@ -201,6 +203,8 @@ TEST_CASE("JSON Node Metadata") } } +// Test extending nlohmann::json by using a custom base class. +// Add a custom member function template iterating over the whole json tree. class visitor_adaptor { public: