mirror of
https://github.com/nlohmann/json.git
synced 2025-07-31 10:24:23 +03:00
Allow custom base class as node customization point (#3110)
Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com> Co-authored-by: Florian Albrechtskirchinger <falbrechtskirchinger@gmail.com> Co-authored-by: barcode <barcode@example.com>
This commit is contained in:
31
include/nlohmann/detail/json_custom_base_class.hpp
Normal file
31
include/nlohmann/detail/json_custom_base_class.hpp
Normal file
@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <type_traits> // conditional, is_same
|
||||
|
||||
#include <nlohmann/detail/abi_macros.hpp>
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
/*!
|
||||
@brief Default base class of the @ref basic_json class.
|
||||
|
||||
So that the correct implementations of the copy / move ctors / assign operators
|
||||
of @ref basic_json do 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<class T>
|
||||
using json_base_class = typename std::conditional <
|
||||
std::is_same<T, void>::value,
|
||||
json_default_base,
|
||||
T
|
||||
>::type;
|
||||
|
||||
} // namespace detail
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
Reference in New Issue
Block a user